Quote:
Originally Posted by phazorRise
i have no idea about UNION.
|
You have to have same columns to get results (and to avoid errors) and all selects are accumulated, same as a simgle one. You can select form more than one table, but maintain the column alias, like this
You have 3 columns, named c1, c2, c3.
Every subselect must return those 3 columns, named the same, even if some are simple strings.
SELECT c1, c2, c3 FROM (
( SELECT someField as c1, another as c2, other c3 FROM someTable )
UNION ALL
( SELECT SUM(field1) c1, anotherField c2, lastOne c3 FROM anotherTable )
UNION ALL
( SELECT field1 c1, anotherField c2, 'simpleString' as c3 FROM anotherTable )
) t1
You can see some examples
reading mysql website
Quote:
|
actual records can be like 3,6,9
|
Of course thay can! Some system that uses keys "maintained as numerically sequential" is just wrong... it's just not designed by a programmer. Primary keys are meant to be unique, not to identify some imaginary sequence. If for some reasons those systems exists, they are just exceptions.
edit // Oh, I assumed that it's about MySql because PHP working with other DBMS is just a rare thing. So, yes Chris, I made some suppositions

I didn't have no reason or intention to upset you but (sorry if I did that), I just wrote my opinion.