onedumbcoder Posted September 8, 2009 Share Posted September 8, 2009 I have a list of ids (1,2,3,4,5,6,7) and I have a groupid(2) book id groud_id 1 2 2 2 3 2 4 2 5 2 6 2 now what I need is for a insert query to execute only if the list id I give it all belong to group 2 Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/ Share on other sites More sharing options...
Maq Posted September 8, 2009 Share Posted September 8, 2009 What's your question? Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/#findComment-914952 Share on other sites More sharing options...
cbolson Posted September 8, 2009 Share Posted September 8, 2009 Use WHERE, same as you would with a SELECT query. eg. INSERT INTO _your_table SET (fields...) VALUES (data...) WHERE group_id=2 Chris Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/#findComment-914955 Share on other sites More sharing options...
onedumbcoder Posted September 8, 2009 Author Share Posted September 8, 2009 never mind, it is not possible to do what I want with mysql. Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/#findComment-914957 Share on other sites More sharing options...
Maq Posted September 8, 2009 Share Posted September 8, 2009 cbolson, you can't use a WHERE clause with INSERT. Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/#findComment-914966 Share on other sites More sharing options...
cbolson Posted September 8, 2009 Share Posted September 8, 2009 opps, sorry, I was getting mixed up with an ALTER. sorry too much other stuff going on at the moment Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/#findComment-914968 Share on other sites More sharing options...
onedumbcoder Posted September 8, 2009 Author Share Posted September 8, 2009 cbolson, you can't use a WHERE clause with INSERT. You are both wrong. You can use a WHERE in a insert statement, but not with the syntax typed above. INSERT INTO tableA(id,name) SELECT id, name FROM tableB WHERE age > 33 Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/#findComment-914969 Share on other sites More sharing options...
Maq Posted September 8, 2009 Share Posted September 8, 2009 Hmm, yeah I guess you're right. But, it's really with/for the SELECT, not the the INSERT. Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/#findComment-914976 Share on other sites More sharing options...
fenway Posted September 10, 2009 Share Posted September 10, 2009 So, where do we stand? Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/#findComment-916290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.