0

This is based on a search engine

I am receiving duplicate search results from this...

$construct ="SELECT * FROM Rating, Attraction WHERE $construct" ;

Then I was informed that it was selecting all results and rows and therefore repeating it so i used this query from another page I have and added the relevant WHERE on the bottom.

$construct  = "SELECT Attraction.*, Type.TypeName, Rating.RatingUrl ";
$construct .= "FROM Attraction ";
$construct .= "INNER JOIN Type ON Attraction.Type = Type.TypeID ";
$construct .= "INNER JOIN Rating ON Attraction.AttractionID = Rating.AttractionID ";
$construct .= "WHERE Attraction = '$construct' ";

Have do i structure this correctly, it is not working and recognising the query.

$construct is a query for matching keywords with the database

Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187

3 Answers3

1

The var you store your query in is called $construct and you are also including it on the last line "WHERE Attraction = '$construct' " so you are actually including the first 4 lines inside the last line, which wont give desired result.

Perhaps renaming the query variable to make it work is enough.

Also if you dont want duplicates, just use DISTINCT

SELECT DISTINCT * FROM Rating, Attraction WHERE $construct
Hugo Delsing
  • 13,803
  • 5
  • 45
  • 72
1

I believe it is because of this

 $construct .= "WHERE Attraction = '$construct' ";

U are using the same variable name ?

v0d1ch
  • 2,738
  • 1
  • 22
  • 27
0

i am not sure but please user group by TypeID may be its work

vaibhav
  • 129
  • 4