The create table user_info {
Id int primary key,
The name varchar (20)
}
The create table order_info {
Id int primary key,
Order_user_id int,
Examine_user_id int
}
User_info is a user table, order_info through order_user_id, examine_user_id associated user table, now my demand is that the query only once user_info, to query the order_user_id and examine_user_id respectively by the corresponding user name
Similar
Select
The from
User_info user_info, order_info order_info
Could you tell me how to write SQL to?
CodePudding user response:
SELECT * FROM ` jssb_user ` u LEFT JOIN ` jssb_subscribe_order ` o ON u.i d=o.u ser_id LEFT JOIN ` jssb_subscribe_order ` a ON u.i d=a.c addie_id WHERE o.a id=2 for your database and the corresponding conditions jssb_user=user_info jssb_subscribe_order=order_infoCodePudding user response: