Say I have 3 columns named ‘page’, ‘book info’ with various values one being ‘author’, the and ‘book data’ where I would have values such as ‘dan brown’, ‘moliere’… I could have many pages with moliere being the author. My query is currently:
$data = mysql_query("SELECT * FROM table WHERE 'book info' = 'author'")
while($info = mysql_fetch_array( $data )) { echo $info['book data']; }
This lists all of the authors, as said earlier ‘moliere’ appears many times, how would I only list an author once?
You can say to the RDBMS to return only distinct rows either with the DISTINCT keyword:
So MySQL will return only one row for each different
book datavalue.Or with a GROUP: