If I have

SELECT a, b
FROM tableA
WHERE Dept = 1

UNION

SELECT a, b
FROM tableB

without any OrderBy clause, what order will the results be in?  tableA rows
followed by tableB rows, or could they be in any order at all?


Second question.  If I have UNION on two selects from the same table, eg:

SELECT a
FROM tableA
WHERE Dept = 1

UNION

SELECT a
FROM tableA
WHERE foo  = 'bar'

The two selects don't return mutually exclusive rows, i.e. there is an
overlap. Assume my table looks like

ID    Dept    foo
1      1           bar
2      1           notbar
3      2           bar
4      3           notbar

first select would return rows with ID 1 and 2
second select would return rows with ID 1 and 3
Overall would the Union give me 1, 2, 3, or would it give me 1, 2, 1, 3?


Duncan Cumming
IT Manager

http://www.alienationdesign.co.uk
mailto:[EMAIL PROTECTED]
Tel: 0141 575 9700
Fax: 0141 575 9600

Creative solutions in a technical world

----------------------------------------------------------------------
Get your domain names online from:
http://www.alienationdomains.co.uk
Reseller options available!
----------------------------------------------------------------------
----------------------------------------------------------------------


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to