| | |
| Stránka: 1 z 1
| [ Príspevkov: 3 ] | |
Autor | Správa |
---|
Registrovaný: 10.10.06 Prihlásený: 13.05.14 Príspevky: 26 Témy: 3 | Napísal stenly: 27.02.2011 7:25 | |
|
Kód: select stlpec1, stlpec2, stlpec3 from tab1 where stlpec3 is not null union all select stlpec1, stlpec2, stlpec3 from tab2 where stlpec3 is not null order by stlpec3 desc
Vypise riadky z dvoch tabuliek zoradene podla stlpca3.
Ako upravit dotaz aby som vedel z ktorej tabulky su jednotlive riadky?
|
|
Registrovaný: 01.04.10 Prihlásený: 08.10.11 Príspevky: 339 Témy: 0 | Napísal Forty-: 27.02.2011 15:25 | |
|
selectni si k tomu meno tabulky
neviem aku mas DB ale pre MySQL by to mohlo vyzerat nejak takto:
Kód: select stlpec1, stlpec2, stlpec3, table_name from tab1, information_schema.tables where stlpec3 is not null and table_name = 'tab1' union all select stlpec1, stlpec2, stlpec3, table_name from tab2, information_schema.tables where stlpec3 is not null and table_name = 'tab2' order by stlpec3 desc
|
|
Registrovaný: 29.10.08 Prihlásený: 30.07.12 Príspevky: 933 Témy: 2 | Napísal coldak: 27.02.2011 16:57 | |
|
Kód: select stlpec1, stlpec2, stlpec3, 'tab1' as stlpec4 from tab1 where stlpec3 is not null union all select stlpec1, stlpec2, stlpec3, 'tab2' as stlpec4 from tab2 where stlpec3 is not null order by stlpec3 desc
|
|
| Stránka: 1 z 1
| [ Príspevkov: 3 ] | |
| Nemôžete zakladať nové témy v tomto fóre Nemôžete odpovedať na témy v tomto fóre Nemôžete upravovať svoje príspevky v tomto fóre Nemôžete mazať svoje príspevky v tomto fóre
|
|