> Hi guys,
>
> Wonder if you can help me with this.
>
> I have a "recording_global" table which has "recording_global_id" in and
> "dj_global_id".
>
> I want to be able to sort the "recording_global" table alphabetically by
> dj name which I need to find from the "dj_global_id" table referencing
> it from the ID in the "recording_global" table and enter it into a
> script.
>
> I have been banging my brain all afternoon but am no nearer to the
> solution. Below is the code I got upto before I realised I was stuck.
>
> $sql = "SELECT * FROM recording_global ORDER BY recording_global_name
> WHERE recording_global_name LIKE a%";
>
> Any help hugely appreciated! Ian.

I think you want:

SELECT r.* FROM recording_global r, dj_global d WHERE
  r.dj_global_id = d.dj_global_id AND r.recording_global_name LIKE 'a%'
  ORDER BY d.dj_global_name

or something like that. You're query is completely wrong since it has the
ORDER BY clause before the WHERE clause.

Read the manual or do some searching on JOINs, as that's what you're going
to need to solve this problem, if I understand it correctly.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to