Toms Posted December 19, 2005 Report Share Posted December 19, 2005 (edited) Izpildu šo SQL pieprasījumu: $query = "SELECT id,from_id,to_id FROM msg_table WHERE (from_id = $u->id AND from_del = 0) OR (to_id = $u->id AND to_del = 0)"; Šis pieprasījums atgriež: 2 - 10 - 11 3 - 11 - 10 4 - 10 - 11 5 - 11 - 10 6 - 10 - 13 7 - 12 - 10 Vajag, lai atgriež: 10 11 12 13 Respektīvi - lai atgriež visus atšķirīgos skaitļus. Ar DISTINCT kaut kā nesanāk... EDIT: Pagaidām iegūtos skaitļus izlaižu caur ciklu, kurā atlasu atšķirīgos.... Edited December 19, 2005 by Toms Link to comment Share on other sites More sharing options...
v3rb0 Posted December 19, 2005 Report Share Posted December 19, 2005 group by [unikālais_lauks] Link to comment Share on other sites More sharing options...
Toms Posted December 19, 2005 Author Report Share Posted December 19, 2005 Kā ar GROUP BY, ja man no divām kolonnām jādabū ārā visi atšķirīgie? Link to comment Share on other sites More sharing options...
[Ya] Posted December 19, 2005 Report Share Posted December 19, 2005 tev vienam laukam jābūt kā Key, attiecīgi to lauku arī norādi kā group by Link to comment Share on other sites More sharing options...
v3rb0 Posted December 19, 2005 Report Share Posted December 19, 2005 laikam vajag unikālos no abām kolonām kopā: thipa selectē primo kolonu, selektē otro kolonu, abas ar union apvieno un beigās group by? Link to comment Share on other sites More sharing options...
Toms Posted December 19, 2005 Author Report Share Posted December 19, 2005 v3rb0, tas der, thnx. Nebiju iedoaajies par UNION.. Link to comment Share on other sites More sharing options...
Recommended Posts