Page 1 of 1

Newb needing the Results from 3 fields matching from query.

Posted: Wed Oct 18, 2006 11:18 pm
by ridshack
Could someone give me advice on how I would query the database and present only the results that matched my criteria? Example:

Database: Office
Table: AForm
Feild1: TechName (Steve)
Feild2: DateRecordEntered (Today)
Field3: ClientName (Brown Inc.)
MoreFileds…..

I want to find only the records that match all three search criteria Steve, Today, and Brown.

Code: Select all

SELECT TechName, DateRocord, ClientName, MoreFields... FROM AForm
 WHERE TechName='$name', DateRecord='$date', ClientName='$client'
Thanks for your help!

Posted: Wed Oct 18, 2006 11:21 pm
by nickvd
Try using OR instead of the comma's... WHERE this=that OR that=theother

Re: Newb needing the Results from 3 fields matching from que

Posted: Wed Oct 18, 2006 11:26 pm
by Zoxive
ridshack wrote:Could someone give me advice on how I would query the database and present only the results that matched my criteria? Example:

Database: Office
Table: AForm
Feild1: TechName (Steve)
Feild2: DateRecordEntered (Today)
Field3: ClientName (Brown Inc.)
MoreFileds…..

I want to find only the records that match all three search criteria Steve, Today, and Brown.

Code: Select all

SELECT TechName, DateRocord, ClientName, MoreFields... FROM AForm
 WHERE TechName='$name', DateRecord='$date', ClientName='$client'
Thanks for your help!
I don't quite understand.. Whats wrong with what you have?

Code: Select all

$name = 'Steve';
$client = 'Brown Inc.';
$today = date("m-d-Y");// Whatever your format is..

Code: Select all

SELECT * From `AForm` WHERE `TechName`='$name' AND `DateRecord`='$today' AND `ClientName`='$client'
-NSF

Posted: Wed Oct 18, 2006 11:58 pm
by ridshack
How obvious now that I see the answer… I need to change the commas to AND

Also I see that OR can be used in different scenarios.

Thanks Everyone.