Jump to content


Photo

Selecting info from table1 depending on a record in table2?


  • Please log in to reply
1 reply to this topic

#1 thenexthour

thenexthour
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 01 December 2003 - 04:52 PM

I have been looking in the MySql Manual but I\'m not quite sure about something so I thought I\'d ask the wonderful people here:

I have a database with two tables; data and jobs. The data table has data about the user while the jobs database has all the information about where the user is looking for a job.

Users are required to register and be verified but before they verify their information they are able to add data to both tables. I want to exclude data from unverified users when someone searched the site. Because the data table holds all the verification information and I want to search the jobs table I don\'t think a simple \'where\' command will cut it and I\'m fairly new to PHP/MySql. Currently I have this:

$sql = \"select * from jobs where name like \'%$job%\';\";

That allows me to search the jobs table but it pulls out both verified and unverified user information re: jobs. I know I can add \'where confirmed = 1\' to the command to exclude unverified info but this only works when qwerying the data table, not the jobs table.... Anyone got a suggestion/solution? I\'ll be searching around for a solution and post it here if I find one; thanks in advance for the mySql help!

Justin

#2 thenexthour

thenexthour
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 December 2003 - 09:09 AM

Rudy from http://r937.com/ gave me the solution on the DevShed site. I thought I\'d share the solution with anyone who is wondering. Thanks again rudy.

select jobs.*  from jobs inner  join data    on jobs.something = data.something where jobs.name like \'%$job%\'   and data.confirmed = 1the "something" columns are whatever columns you defined to link the user to her jobs





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users