php - sql query not giving exact answer -


sql query working last 2 , condition in not giving exact answer

query:

select products.*,wishlist.user_id,wishlist.p_id  products  left join wishlist    on products.pro_id=wishlist.p_id , products.categ_id=2 , wishlist.user_id=5 

your question doesn't specify problem having go through how troubleshoot this.

first, left join presumably want in products table, combined set of things in left join table. there's huge difference outer joins in join condition vs clause.

let's go on few permutations mean. want take @ these first. recommendation start changing inner join , see get. simpler start troubleshooting inner join , go outer join after.

so start with:

select products.*,wishlist.user_id,wishlist.p_id  products  join wishlist  on products.pro_id=wishlist.p_id , products.categ_id=2 , wishlist.user_id=5 

make sure results expect first. figure out want after. if want products, wishlist data appended category 2 , user id, go original query. if want products in category2 user_id's wishlist data this:

select products.*,wishlist.user_id,wishlist.p_id  products  left join wishlist       on products.pro_id=wishlist.p_id , wishlist.user_id=5 products.categ_id=2 

there several other possible permutations unless clear answers looking database, that's best advice can give.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -