I am trying to make a proper subquery....just not sure bout the syntax


I use this this basic query to connect all of my tables:

# here is the basic query that connects all the tables..this works :)
$sql = 'SELECT playlist.name as playlist_name, artist.name as artist,'
. ' artist.'.$language.' as bio,artist.purchaseLink,'
. ' media.'.$language.' as trackName, media.path,media.quality,mediaType.id as mediaType'
. ' FROM playlist, artist, media, playlistItems, mediaType'
. ' WHERE playlistItems.playlist_id = playlist.id'
. ' AND playlistItems.media_id = media.id'
. ' AND media.artist_id = artist.id'
. ' And media.mediaType_id = mediaType.id';




After I connect all my tables, I tried:

# if there is a query string, add it to the above $sql string
if(strcmp($query,"" )!= 0){
$sql = $sql. ' AND media.'.$language.' Like "%'.$query.'%"'
. ' OR artist.'.$language.' Like "%'.$query.'%"'
. ' OR artist.name Like "%'.$query.'%"'
. ' ORDER BY playlist.id ASC,playlistItems.order ASC LIMIT 0, 60';

well, for probably obvious reasons, this does not give the right result
Basically I am searching in  every relevant field for the query string.

what would would be  the correct syntax for this kind of thing ?

many thanks
g


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to