kathas Posted November 25, 2006 Share Posted November 25, 2006 Hello everyone...I have a question, i googled for the answer but couldn't find anything...Can i execute two queries with one mysql_query() statement?Example: [b]mysql_query(two queries here...)[/b]Thanx in advance for all help... Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/ Share on other sites More sharing options...
JasonLewis Posted November 25, 2006 Share Posted November 25, 2006 what exactly do you mean, it is possible to select data from 2 databases like this:[code=php:0]mysql_query("SELECT a.*, b.* FROM `tablea` a, `tableb` b");[/code] Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130011 Share on other sites More sharing options...
kathas Posted November 25, 2006 Author Share Posted November 25, 2006 No i mean sth like this...i mean have this result...[b]mysql_query(SELECT * FROM table)mysql_query(UPDATE table SET.....)[/b]with one mysql_query()...Sorry if i am being hard to understand...Thanx for the help... Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130016 Share on other sites More sharing options...
akitchin Posted November 25, 2006 Share Posted November 25, 2006 simple answer: no.mysql_query() only takes one query at a time, and you cannot separate SQL statements with a semi-colon. as i think projectfear was implying, if you want to run two queries for one resultset, blend your queries. Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130024 Share on other sites More sharing options...
kathas Posted November 25, 2006 Author Share Posted November 25, 2006 Yeah i kind of thought of that answer...thanx a lot [b]akitchin[/b]By blend i guess you mean make two queries right??Anywayz thanx... Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130028 Share on other sites More sharing options...
akitchin Posted November 25, 2006 Share Posted November 25, 2006 no, by blend i meant turn two queries into one query using a JOIN of some sort. Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130031 Share on other sites More sharing options...
kathas Posted November 25, 2006 Author Share Posted November 25, 2006 yeah but you can't really blend SELECT and UPDATE can you?And JOIN clause doesn't blend queries does it???I think it blends results from tables... Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130035 Share on other sites More sharing options...
akitchin Posted November 25, 2006 Share Posted November 25, 2006 yes, but i was under the impression you were running two SELECT queries and wanted the resultset in one resource. i was mistaken. Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130038 Share on other sites More sharing options...
kathas Posted November 25, 2006 Author Share Posted November 25, 2006 Yeah it's ok...Thanx anyway...I found the UNION clause but that's for two SELECT queries also...I don't know if it is possible... to send a SELECT and an UPDATE together ... i start believing it isn't... :) Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130043 Share on other sites More sharing options...
akitchin Posted November 25, 2006 Share Posted November 25, 2006 no, it isn't possible. and i can't see any reason why you wouldnt want to do so, unless you're updating with the results of a SELECT, in which case you'd use a subquery (if they are supported).either way, i don't think you have any reason to merge the SELECT and UPDATE. run them separately. Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130045 Share on other sites More sharing options...
JasonLewis Posted November 25, 2006 Share Posted November 25, 2006 maybe they want to make it looks neater by grouping certain queries. Link to comment https://forums.phpfreaks.com/topic/28419-help-with-mysql_query-statement/#findComment-130279 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.