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 Quote 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? Quote 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 Quote 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. Quote 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. Quote 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 Quote 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 Quote 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. Quote 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? Quote Link to comment https://forums.phpfreaks.com/topic/173580-dear-god-helpppppppp/#findComment-916290 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.