mysql - how to get data from another table based on condition -
i have 2 tables
user_info:
user_id user_name address 1 pavan bangalore 2 balu chennai 3 badra hyd
item_info:
item_id user_id state 1 1 0 2 1 1 3 1 2 4 2 1
i have 1 method gettotaldetails,suppose if login admin need this:
user_id user_name address item_id state 1 pavan bangalore 1 0 1 pavan bangalore 2 1 1 pavan bangalore 3 2 2 balu chennai 4 1 3 badra hyd null null
can show me how write query above data set?
you can :-
select user_id, username, address, item_id, state user_info left join item_info using (user_id)
Comments
Post a Comment