sanjdhiman
Programmer
Hi there I have a pretty easy question for u advanced SQL people
I have a table and it has been set out to store features of a property.
Features1
Features2
Features3
Features4
They are all varchar (50)
Ok so the problem is this
the user selects from a select box on form a keyword for example 'double glazing'
the select statement im trying to write has to search the table with the keyword 'double glazing' in each field, feature1 thru to feature4 because double glazing could be entered in any four of them.
I have this so far but, it doesnt do what i need it to do as stated above:
SELECT *
FROM propertyforsale
WHERE $searchlocation LIKE '%$location[$j]%'
AND NoBedrooms>= $minbed
AND Price>$minprice AND Price<$maxprice
AND(Feature1 = '$features1' OR Feature1 = '$features2' OR Feature1='$features3' OR Feature1='$features4')
OR (Feature2 = '$features1' OR Feature2 = '$features2' OR Feature2='$features3' OR Feature2='$features4')
OR (Feature3 = '$features1' OR Feature3 = '$features2' OR Feature3='$features3' OR Feature3='$features4')
OR (Feature4 = '$features1' OR Feature4 = '$features2' OR Feature4='$features3' OR Feature4='$features4')
ORDER BY $sortby ASC";
What the above SQL returns is too many results, it checks double glazing against the database and returns the ones with double glazing in any of the fields features1 to features4 BUT it then gives me more results
dont know what to do
any help is much appreciated
thanks in advance
anymore info dont hesitate to ask
thanks ppl
sanj
i am writing a select statement that will select all those entries with a certain keyword.
This keyword has to be checked with all 4 fields, i.e. features1 thru to 4
I have a table and it has been set out to store features of a property.
Features1
Features2
Features3
Features4
They are all varchar (50)
Ok so the problem is this
the user selects from a select box on form a keyword for example 'double glazing'
the select statement im trying to write has to search the table with the keyword 'double glazing' in each field, feature1 thru to feature4 because double glazing could be entered in any four of them.
I have this so far but, it doesnt do what i need it to do as stated above:
SELECT *
FROM propertyforsale
WHERE $searchlocation LIKE '%$location[$j]%'
AND NoBedrooms>= $minbed
AND Price>$minprice AND Price<$maxprice
AND(Feature1 = '$features1' OR Feature1 = '$features2' OR Feature1='$features3' OR Feature1='$features4')
OR (Feature2 = '$features1' OR Feature2 = '$features2' OR Feature2='$features3' OR Feature2='$features4')
OR (Feature3 = '$features1' OR Feature3 = '$features2' OR Feature3='$features3' OR Feature3='$features4')
OR (Feature4 = '$features1' OR Feature4 = '$features2' OR Feature4='$features3' OR Feature4='$features4')
ORDER BY $sortby ASC";
What the above SQL returns is too many results, it checks double glazing against the database and returns the ones with double glazing in any of the fields features1 to features4 BUT it then gives me more results
dont know what to do
any help is much appreciated
thanks in advance
anymore info dont hesitate to ask
thanks ppl
sanj
i am writing a select statement that will select all those entries with a certain keyword.
This keyword has to be checked with all 4 fields, i.e. features1 thru to 4