I have a query that inserts using a select:
INSERT INTO courses (name, location, gid)
SELECT name, location, gid
FROM courses
WHERE cid = $cid
Is it possible to only select "name,location" for the insert, and set gid to something else in the query?
I think your INSERT statement is wrong, see correct syntax: http://dev.mysql.com/doc/refman/5.1/en/insert.html
edit: as Andrew already pointed out...
The right Syntax for your query is:
Correct Syntax: select spelling was wrong
Sure, what do you want to use for the gid? a static value, PHP var, ...
A static value of 1234 could be like:
Yes, it is. You can write :
or you can get values from another join of the select ...
Yes, absolutely, but check your syntax.
You can put a constant of the same type as
gid
in its place, not just 1, of course. And, I just made up thecid
value.