PHP SQL & joins

  • Liamw411
  • Novice
  • Novice
  • Liamw411
  • Posts: 27
  • Loc: United Kingdom

Post 3+ Months Ago

Hi all,

I am currently working on a project where I have two tables, user_info and users_list.

I need to select all the data from the users_list table where the related email address in the user_info table is enabled.

I am not so great with SQL, and i have been trying to read up on possible ways to achieve this, from what i have read it would be to use joins.

So i am just wondering, am i correct to be thinking i need to use joins, or does anybody know a better way to achieve to desired outcome.

Many thanks Liam.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Yes that sounds right to me. You would join on what is common between the two tables, so for instance if in the user_lists table you have unique ids for each user, and in the user_info table you have the same ids, then you would join on that.
  • Liamw411
  • Novice
  • Novice
  • Liamw411
  • Posts: 27
  • Loc: United Kingdom

Post 3+ Months Ago

Thanks for your reply it has helped me considerably, I have a basic working version now.
But now I am wondering what is the difference between join, left join, right join & inner/outer join?

Thanks Liamw411.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

CodeProject has a very good explanation of the different joins.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 52 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.