Jump to content


Photo

Help pls. Find records NOT in 1 table but in another


  • Please log in to reply
2 replies to this topic

#1 llandudno

llandudno
  • Members
  • Pip
  • Newbie
  • 2 posts
  • LocationNorth Wales (UK)

Posted 04 July 2006 - 07:21 AM

Hi folks, been away for a bit, and forgotten some things, anyhow, can you pls help.  I have 2 tables in a DB, one contains a list of "rooms' the other is for room availability. - based on date.

All I want to do is find out which rooms are available on certain dates. e.g:

$sql = "SELECT * FROM roomlist
  LEFT JOIN roomavailability ON roomavailability.roomlistID=roomlist.roomlistID
  WHERE roomavailability.datefrom BETWEEN $adate AND $departdate
  AND roomavailability.dateto BETWEEN $adate AND $departdate";
  $rs  = mysql_query($sql) or die("Error: " . mysql_error());
  while ($row = mysql_fetch_array($rs, MYSQL_ASSOC))
  {
  echo  $row['roomlistID'];
  }

This query gives me the right results for rooms that have been booked, but  what I actually want is roomlistID from roomlist if it is not in the above query.  understand?

Help much appreciated, thanks
I know it can be done, I just can't do it

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 04 July 2006 - 07:28 AM

this may be a real dumb answer, but you are saying you want the opposite result, right? did you try

... roomavailability.roomlistID != roomlist.roomlistID ....

?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 llandudno

llandudno
  • Members
  • Pip
  • Newbie
  • 2 posts
  • LocationNorth Wales (UK)

Posted 04 July 2006 - 11:50 AM

Sorry but ... roomID!=roomlist.roomlistID does not give the result I want.
I know it can be done, I just can't do it




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users