> Order is never guaranteed in a SQL statement's resultset, unless this
> statement specifies an ORDER BY clause. If some statement without such a
> clause happens to give you an order you want, it does so by accident. If
> you want a particular order, say so in the statement.
Yeah, which would work for the height example, but then would still
mess up the alternation of the side column.
> It would help if you showed the actual statement you have now, and the
> results you expect.
Apologies.
It would look like this:
FName LName Side Height
------------------------------
Igor Tande A 1
Telly Will B 1
John Smith A 1
Bob Hope B 1
Sandy Rivera A 2
Bobby Sangria B 2
Jane Tane A 2
Tom Jones B 2
SELECT Fname, Lname, Side, Height FROM (SELECT * FROM table WHERE
Side='A' AND ((Height=1) OR (Height=2)) ORDER BY random() LIMIT 1) UNION
SELECT Fname, Lname, Side, Height FROM (SELECT * FROM table WHERE
Side='B' AND ((Height=1) OR (Height=2)) ORDER BY random() LIMIT 1) UNION
SELECT Fname, Lname, Side, Height FROM (SELECT * FROM table WHERE
Side='A' AND ((Height=1) OR (Height=2)) ORDER BY random() LIMIT 1);
With the UNION statement above I might get:
FName LName Side Height
------------------------------
Jane Tane A 2
Igor Tande A 1
Tom Jones B 2
The Height is out of order (not 1, 2, 2). If I use a UNION ALL
then I might get:
FName LName Side Height
------------------------------
John Smith A 1
Telly Will B 1
John Smith A 1
See the duplicate? I'm doing this in a C++ program, so I'm thinking
that
I might have to run individual SELECT statements for each one in the order that
I
need.
--
VR~
TW
Email: [EMAIL PROTECTED]
"Knowledge Is Power"
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users