l!m!t Posted November 1, 2006 Share Posted November 1, 2006 Hello, Hopefully someone can help me I have been at this for hours. I am trying to call two tables in one mysql query.(see below ) $limit1 = "update " . CUSTOMERS . " set member_level = '10' [b]where orders_status_id =7 ";[/b]order_status is located in a table called [b]ORDERS [/b]I cant figure out how to get that in the query. I have tried a Join command and still wont work. Everything else seems to work in basically just cant find "order_status", which is located in a table called ORDERS.Any help would be very much appreocated! Link to comment https://forums.phpfreaks.com/topic/25782-php-call-2-tables-from-one-query-please-help/ Share on other sites More sharing options...
redarrow Posted November 1, 2006 Share Posted November 1, 2006 This would set member_level to 10 and orders to 10 with the order status of 7[code]$query ="update customers set members_level='10' , orders='10' where order_status='7' ";[/code] Link to comment https://forums.phpfreaks.com/topic/25782-php-call-2-tables-from-one-query-please-help/#findComment-117726 Share on other sites More sharing options...
l!m!t Posted November 1, 2006 Author Share Posted November 1, 2006 Hi thanks for the reply. Order is actually a seperate table (eg The formatting is probably not right, but is what I am trying to do. [code]$limit1 = "update " . CUSTOMERS . " set member_level = '10' where " . TABLE_ORDERS . " orders_status_id =7 ";[/code] I want it to only update where the order_status_id =7 , the only thing I cant figure out is how to query the ORDERS table in the same call. Link to comment https://forums.phpfreaks.com/topic/25782-php-call-2-tables-from-one-query-please-help/#findComment-117728 Share on other sites More sharing options...
Orio Posted November 1, 2006 Share Posted November 1, 2006 Can you explain again?You want to set member_level in CUSTOMERS table to 10 if that member has order_status_id set to 7 in the table called TABLE_ORDERS?I [i]think[/i] this how it's done, but I really not sure-"UPDATE ".CUSTOMERS." SET member_level = '10' WHERE member IN (SELECT member FROM ".TABLE_ORDERS." WHERE orders_status_id = '7')"Like I said, I am not sure.Orio. Link to comment https://forums.phpfreaks.com/topic/25782-php-call-2-tables-from-one-query-please-help/#findComment-117736 Share on other sites More sharing options...
redarrow Posted November 1, 2006 Share Posted November 1, 2006 if what orio has posted is correct please let us no as i am learning mysql heavly and i have never seen that sql statement before let me no cheers.intresting nice code orio. Link to comment https://forums.phpfreaks.com/topic/25782-php-call-2-tables-from-one-query-please-help/#findComment-117756 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.