1307
1355
select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;
1358
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1359
id select_type table type possible_keys key key_len ref rows Extra
1360
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200
1361
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists
1362
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
1363
id select_type table type possible_keys key key_len ref rows Extra
1364
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1365
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists
1310
1366
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1311
1367
companynr companyname
1312
1368
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
1371
explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
1372
id select_type table type possible_keys key key_len ref rows Extra
1373
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
1374
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
1375
id select_type table type possible_keys key key_len ref rows Extra
1376
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
1315
1377
delete from t2 where fld1=999999;
1378
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
1379
id select_type table type possible_keys key key_len ref rows Extra
1380
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1381
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
1382
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
1383
id select_type table type possible_keys key key_len ref rows Extra
1384
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1385
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
1386
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
1387
id select_type table type possible_keys key key_len ref rows Extra
1388
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1389
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
1390
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
1391
id select_type table type possible_keys key key_len ref rows Extra
1392
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1393
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1394
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
1395
id select_type table type possible_keys key key_len ref rows Extra
1396
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1397
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1398
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
1399
id select_type table type possible_keys key key_len ref rows Extra
1400
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1401
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1402
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
1403
id select_type table type possible_keys key key_len ref rows Extra
1404
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1405
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1406
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
1407
id select_type table type possible_keys key key_len ref rows Extra
1408
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12
1409
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1410
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
1411
id select_type table type possible_keys key key_len ref rows Extra
1412
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1413
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1414
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
1415
id select_type table type possible_keys key key_len ref rows Extra
1416
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1417
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1418
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
1419
id select_type table type possible_keys key key_len ref rows Extra
1420
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1421
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1422
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
1423
id select_type table type possible_keys key key_len ref rows Extra
1424
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where
1425
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
1316
1426
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1317
1427
companynr companynr
1430
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
1431
id select_type table type possible_keys key key_len ref rows Extra
1432
1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
1433
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer
1320
1434
select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
1321
1435
fld1 companynr fld3 period
1322
38008 37 reporters 1008
1323
38208 37 Selfridge 1008
1436
038008 37 reporters 1008
1437
038208 37 Selfridge 1008
1324
1438
select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
1325
1439
fld1 companynr fld3 period
1326
38008 37 reporters 1008
1327
38208 37 Selfridge 1008
1440
038008 37 reporters 1008
1441
038208 37 Selfridge 1008
1328
1442
select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
1329
1443
fld1 companynr fld3 period
1330
38008 37 reporters 1008
1331
38208 37 Selfridge 1008
1444
038008 37 reporters 1008
1445
038208 37 Selfridge 1008
1332
1446
select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
1625
1744
select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4;
1626
1745
fld4 fld1 count(price) sum(price) min(price) max(price) avg(price)
1627
teethe 1 1 5987435 5987435 5987435 5987435.0000
1628
dreaded 11401 1 5987435 5987435 5987435 5987435.0000
1629
scholastics 11402 1 28357832 28357832 28357832 28357832.0000
1630
audiology 11403 1 39654943 39654943 39654943 39654943.0000
1631
wallet 11501 1 5987435 5987435 5987435 5987435.0000
1632
parters 11701 1 5987435 5987435 5987435 5987435.0000
1633
eschew 11702 1 28357832 28357832 28357832 28357832.0000
1634
quitter 11703 1 39654943 39654943 39654943 39654943.0000
1635
neat 12001 1 5987435 5987435 5987435 5987435.0000
1636
Steinberg 12003 1 39654943 39654943 39654943 39654943.0000
1637
balled 12301 1 5987435 5987435 5987435 5987435.0000
1638
persist 12302 1 28357832 28357832 28357832 28357832.0000
1639
attainments 12303 1 39654943 39654943 39654943 39654943.0000
1640
capably 12501 1 5987435 5987435 5987435 5987435.0000
1641
impulsive 12602 1 28357832 28357832 28357832 28357832.0000
1642
starlet 12603 1 39654943 39654943 39654943 39654943.0000
1643
featherweight 12701 1 5987435 5987435 5987435 5987435.0000
1644
pessimist 12702 1 28357832 28357832 28357832 28357832.0000
1645
daughter 12703 1 39654943 39654943 39654943 39654943.0000
1646
lawgiver 13601 1 5987435 5987435 5987435 5987435.0000
1647
stated 13602 1 28357832 28357832 28357832 28357832.0000
1648
readable 13603 1 39654943 39654943 39654943 39654943.0000
1649
testicle 13801 1 5987435 5987435 5987435 5987435.0000
1650
Parsifal 13802 1 28357832 28357832 28357832 28357832.0000
1651
leavings 13803 1 39654943 39654943 39654943 39654943.0000
1652
squeaking 13901 1 5987435 5987435 5987435 5987435.0000
1653
contrasted 16001 1 5987435 5987435 5987435 5987435.0000
1654
leftover 16201 1 5987435 5987435 5987435 5987435.0000
1655
whiteners 16202 1 28357832 28357832 28357832 28357832.0000
1656
erases 16301 1 5987435 5987435 5987435 5987435.0000
1657
Punjab 16302 1 28357832 28357832 28357832 28357832.0000
1658
Merritt 16303 1 39654943 39654943 39654943 39654943.0000
1659
sweetish 18001 1 5987435 5987435 5987435 5987435.0000
1660
dogging 18002 1 28357832 28357832 28357832 28357832.0000
1661
scornfully 18003 1 39654943 39654943 39654943 39654943.0000
1662
fetters 18012 1 28357832 28357832 28357832 28357832.0000
1663
bivalves 18013 1 39654943 39654943 39654943 39654943.0000
1664
skulking 18021 1 5987435 5987435 5987435 5987435.0000
1665
flint 18022 1 28357832 28357832 28357832 28357832.0000
1666
flopping 18023 1 39654943 39654943 39654943 39654943.0000
1667
Judas 18032 1 28357832 28357832 28357832 28357832.0000
1668
vacuuming 18033 1 39654943 39654943 39654943 39654943.0000
1669
medical 18041 1 5987435 5987435 5987435 5987435.0000
1670
bloodbath 18042 1 28357832 28357832 28357832 28357832.0000
1671
subschema 18043 1 39654943 39654943 39654943 39654943.0000
1672
interdependent 18051 1 5987435 5987435 5987435 5987435.0000
1673
Graves 18052 1 28357832 28357832 28357832 28357832.0000
1674
neonatal 18053 1 39654943 39654943 39654943 39654943.0000
1675
sorters 18061 1 5987435 5987435 5987435 5987435.0000
1676
epistle 18062 1 28357832 28357832 28357832 28357832.0000
1677
Conley 18101 1 5987435 5987435 5987435 5987435.0000
1678
lectured 18102 1 28357832 28357832 28357832 28357832.0000
1679
Abraham 18103 1 39654943 39654943 39654943 39654943.0000
1680
cage 18201 1 5987435 5987435 5987435 5987435.0000
1681
hushes 18202 1 28357832 28357832 28357832 28357832.0000
1682
Simla 18402 1 28357832 28357832 28357832 28357832.0000
1683
reporters 18403 1 39654943 39654943 39654943 39654943.0000
1684
coexist 18601 1 5987435 5987435 5987435 5987435.0000
1685
Beebe 18602 1 28357832 28357832 28357832 28357832.0000
1686
Taoism 18603 1 39654943 39654943 39654943 39654943.0000
1687
Connally 18801 1 5987435 5987435 5987435 5987435.0000
1688
fetched 18802 1 28357832 28357832 28357832 28357832.0000
1689
checkpoints 18803 1 39654943 39654943 39654943 39654943.0000
1690
gritty 18811 1 5987435 5987435 5987435 5987435.0000
1691
firearm 18812 1 28357832 28357832 28357832 28357832.0000
1692
minima 19101 1 5987435 5987435 5987435 5987435.0000
1693
Selfridge 19102 1 28357832 28357832 28357832 28357832.0000
1694
disable 19103 1 39654943 39654943 39654943 39654943.0000
1695
witchcraft 19201 1 5987435 5987435 5987435 5987435.0000
1696
betroth 30501 1 5987435 5987435 5987435 5987435.0000
1697
Manhattanize 30502 1 28357832 28357832 28357832 28357832.0000
1698
imprint 30503 1 39654943 39654943 39654943 39654943.0000
1699
swelling 31901 1 5987435 5987435 5987435 5987435.0000
1700
interrelationships 36001 1 5987435 5987435 5987435 5987435.0000
1701
riser 36002 1 28357832 28357832 28357832 28357832.0000
1702
bee 38001 1 5987435 5987435 5987435 5987435.0000
1703
kanji 38002 1 28357832 28357832 28357832 28357832.0000
1704
dental 38003 1 39654943 39654943 39654943 39654943.0000
1705
railway 38011 1 5987435 5987435 5987435 5987435.0000
1706
validate 38012 1 28357832 28357832 28357832 28357832.0000
1707
normalizes 38013 1 39654943 39654943 39654943 39654943.0000
1708
Kline 38101 1 5987435 5987435 5987435 5987435.0000
1709
Anatole 38102 1 28357832 28357832 28357832 28357832.0000
1710
partridges 38103 1 39654943 39654943 39654943 39654943.0000
1711
recruited 38201 1 5987435 5987435 5987435 5987435.0000
1712
dimensions 38202 1 28357832 28357832 28357832 28357832.0000
1713
Chicana 38203 1 39654943 39654943 39654943 39654943.0000
1746
teethe 000001 1 5987435 5987435 5987435 5987435.0000
1747
dreaded 011401 1 5987435 5987435 5987435 5987435.0000
1748
scholastics 011402 1 28357832 28357832 28357832 28357832.0000
1749
audiology 011403 1 39654943 39654943 39654943 39654943.0000
1750
wallet 011501 1 5987435 5987435 5987435 5987435.0000
1751
parters 011701 1 5987435 5987435 5987435 5987435.0000
1752
eschew 011702 1 28357832 28357832 28357832 28357832.0000
1753
quitter 011703 1 39654943 39654943 39654943 39654943.0000
1754
neat 012001 1 5987435 5987435 5987435 5987435.0000
1755
Steinberg 012003 1 39654943 39654943 39654943 39654943.0000
1756
balled 012301 1 5987435 5987435 5987435 5987435.0000
1757
persist 012302 1 28357832 28357832 28357832 28357832.0000
1758
attainments 012303 1 39654943 39654943 39654943 39654943.0000
1759
capably 012501 1 5987435 5987435 5987435 5987435.0000
1760
impulsive 012602 1 28357832 28357832 28357832 28357832.0000
1761
starlet 012603 1 39654943 39654943 39654943 39654943.0000
1762
featherweight 012701 1 5987435 5987435 5987435 5987435.0000
1763
pessimist 012702 1 28357832 28357832 28357832 28357832.0000
1764
daughter 012703 1 39654943 39654943 39654943 39654943.0000
1765
lawgiver 013601 1 5987435 5987435 5987435 5987435.0000
1766
stated 013602 1 28357832 28357832 28357832 28357832.0000
1767
readable 013603 1 39654943 39654943 39654943 39654943.0000
1768
testicle 013801 1 5987435 5987435 5987435 5987435.0000
1769
Parsifal 013802 1 28357832 28357832 28357832 28357832.0000
1770
leavings 013803 1 39654943 39654943 39654943 39654943.0000
1771
squeaking 013901 1 5987435 5987435 5987435 5987435.0000
1772
contrasted 016001 1 5987435 5987435 5987435 5987435.0000
1773
leftover 016201 1 5987435 5987435 5987435 5987435.0000
1774
whiteners 016202 1 28357832 28357832 28357832 28357832.0000
1775
erases 016301 1 5987435 5987435 5987435 5987435.0000
1776
Punjab 016302 1 28357832 28357832 28357832 28357832.0000
1777
Merritt 016303 1 39654943 39654943 39654943 39654943.0000
1778
sweetish 018001 1 5987435 5987435 5987435 5987435.0000
1779
dogging 018002 1 28357832 28357832 28357832 28357832.0000
1780
scornfully 018003 1 39654943 39654943 39654943 39654943.0000
1781
fetters 018012 1 28357832 28357832 28357832 28357832.0000
1782
bivalves 018013 1 39654943 39654943 39654943 39654943.0000
1783
skulking 018021 1 5987435 5987435 5987435 5987435.0000
1784
flint 018022 1 28357832 28357832 28357832 28357832.0000
1785
flopping 018023 1 39654943 39654943 39654943 39654943.0000
1786
Judas 018032 1 28357832 28357832 28357832 28357832.0000
1787
vacuuming 018033 1 39654943 39654943 39654943 39654943.0000
1788
medical 018041 1 5987435 5987435 5987435 5987435.0000
1789
bloodbath 018042 1 28357832 28357832 28357832 28357832.0000
1790
subschema 018043 1 39654943 39654943 39654943 39654943.0000
1791
interdependent 018051 1 5987435 5987435 5987435 5987435.0000
1792
Graves 018052 1 28357832 28357832 28357832 28357832.0000
1793
neonatal 018053 1 39654943 39654943 39654943 39654943.0000
1794
sorters 018061 1 5987435 5987435 5987435 5987435.0000
1795
epistle 018062 1 28357832 28357832 28357832 28357832.0000
1796
Conley 018101 1 5987435 5987435 5987435 5987435.0000
1797
lectured 018102 1 28357832 28357832 28357832 28357832.0000
1798
Abraham 018103 1 39654943 39654943 39654943 39654943.0000
1799
cage 018201 1 5987435 5987435 5987435 5987435.0000
1800
hushes 018202 1 28357832 28357832 28357832 28357832.0000
1801
Simla 018402 1 28357832 28357832 28357832 28357832.0000
1802
reporters 018403 1 39654943 39654943 39654943 39654943.0000
1803
coexist 018601 1 5987435 5987435 5987435 5987435.0000
1804
Beebe 018602 1 28357832 28357832 28357832 28357832.0000
1805
Taoism 018603 1 39654943 39654943 39654943 39654943.0000
1806
Connally 018801 1 5987435 5987435 5987435 5987435.0000
1807
fetched 018802 1 28357832 28357832 28357832 28357832.0000
1808
checkpoints 018803 1 39654943 39654943 39654943 39654943.0000
1809
gritty 018811 1 5987435 5987435 5987435 5987435.0000
1810
firearm 018812 1 28357832 28357832 28357832 28357832.0000
1811
minima 019101 1 5987435 5987435 5987435 5987435.0000
1812
Selfridge 019102 1 28357832 28357832 28357832 28357832.0000
1813
disable 019103 1 39654943 39654943 39654943 39654943.0000
1814
witchcraft 019201 1 5987435 5987435 5987435 5987435.0000
1815
betroth 030501 1 5987435 5987435 5987435 5987435.0000
1816
Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000
1817
imprint 030503 1 39654943 39654943 39654943 39654943.0000
1818
swelling 031901 1 5987435 5987435 5987435 5987435.0000
1819
interrelationships 036001 1 5987435 5987435 5987435 5987435.0000
1820
riser 036002 1 28357832 28357832 28357832 28357832.0000
1821
bee 038001 1 5987435 5987435 5987435 5987435.0000
1822
kanji 038002 1 28357832 28357832 28357832 28357832.0000
1823
dental 038003 1 39654943 39654943 39654943 39654943.0000
1824
railway 038011 1 5987435 5987435 5987435 5987435.0000
1825
validate 038012 1 28357832 28357832 28357832 28357832.0000
1826
normalizes 038013 1 39654943 39654943 39654943 39654943.0000
1827
Kline 038101 1 5987435 5987435 5987435 5987435.0000
1828
Anatole 038102 1 28357832 28357832 28357832 28357832.0000
1829
partridges 038103 1 39654943 39654943 39654943 39654943.0000
1830
recruited 038201 1 5987435 5987435 5987435 5987435.0000
1831
dimensions 038202 1 28357832 28357832 28357832 28357832.0000
1832
Chicana 038203 1 39654943 39654943 39654943 39654943.0000
1714
1833
select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3;
1715
1834
companynr fld3 sum(price)
1716
1835
512 boat 786542
1940
2068
Tables_in_test (t?)
1941
2069
show full columns from t2;
1942
2070
Field Type Collation Null Key Default Extra Privileges Comment
1943
auto int NULL NO PRI NULL auto_increment #
1944
fld1 int NULL NO UNI NULL #
1945
companynr int NULL NO NULL #
1946
fld3 varchar(30) utf8_general_ci NO MUL NULL #
1947
fld4 varchar(35) utf8_general_ci NO NULL #
1948
fld5 varchar(35) utf8_general_ci NO NULL #
1949
fld6 varchar(4) utf8_general_ci NO NULL #
2071
auto int(11) NULL NO PRI NULL auto_increment #
2072
fld1 int(6) unsigned zerofill NULL NO UNI NULL #
2073
companynr tinyint(2) unsigned zerofill NULL NO NULL #
2074
fld3 char(30) latin1_swedish_ci NO MUL NULL #
2075
fld4 char(35) latin1_swedish_ci NO NULL #
2076
fld5 char(35) latin1_swedish_ci NO NULL #
2077
fld6 char(4) latin1_swedish_ci NO NULL #
1950
2078
show full columns from t2 from test like 'f%';
1951
2079
Field Type Collation Null Key Default Extra Privileges Comment
1952
fld1 int NULL NO UNI NULL #
1953
fld3 varchar(30) utf8_general_ci NO MUL NULL #
1954
fld4 varchar(35) utf8_general_ci NO NULL #
1955
fld5 varchar(35) utf8_general_ci NO NULL #
1956
fld6 varchar(4) utf8_general_ci NO NULL #
2080
fld1 int(6) unsigned zerofill NULL NO UNI NULL #
2081
fld3 char(30) latin1_swedish_ci NO MUL NULL #
2082
fld4 char(35) latin1_swedish_ci NO NULL #
2083
fld5 char(35) latin1_swedish_ci NO NULL #
2084
fld6 char(4) latin1_swedish_ci NO NULL #
1957
2085
show full columns from t2 from test like 's%';
1958
2086
Field Type Collation Null Key Default Extra Privileges Comment
2088
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
2089
t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE
2090
t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE
2091
t2 1 fld3 1 fld3 A NULL NULL NULL BTREE
1959
2092
drop table t4, t3, t2, t1;
1960
2093
CREATE TABLE t1 (
1961
id bigint NOT NULL auto_increment,
2094
id bigint(8) unsigned NOT NULL auto_increment,
1962
2095
pseudo varchar(35) NOT NULL default '',
1963
2096
PRIMARY KEY (id),
1964
2097
UNIQUE KEY pseudo (pseudo)
1968
2101
SELECT 1 as rnd1 from t1 where rand() > 2;
1971
CREATE TABLE t1 (gvid int default NULL, hmid int default NULL, volid int default NULL, mmid int default NULL, hdid int default NULL, fsid int default NULL, ctid int default NULL, dtid int default NULL, cost int default NULL, performance int default NULL, serialnumber bigint default NULL, monitored int default '1', removed int default '0', target int default '0', dt_modified timestamp NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM;
2104
CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM;
1972
2105
INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL);
1973
CREATE TABLE t2 ( hmid int default NULL, volid int default NULL, sampletid int default NULL, sampletime datetime default NULL, samplevalue bigint default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM;
2106
CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM;
1974
2107
INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35);
1975
2108
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
1976
2109
gvid the_success the_fail the_size the_time
2359
CREATE TABLE t1 (b BIGINT NOT NULL, PRIMARY KEY (b));
2360
INSERT INTO t1 VALUES (0x4000000000000000);
2361
SELECT b FROM t1 WHERE b=0x4000000000000000;
2508
CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b));
2509
INSERT INTO t1 VALUES (0x8000000000000000);
2510
SELECT b FROM t1 WHERE b=0x8000000000000000;
2365
CREATE TABLE `t1` ( `gid` int default NULL, `uid` int default NULL);
2366
CREATE TABLE `t2` ( `ident` int default NULL, `level` char(16) default NULL);
2514
CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
2515
CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
2367
2516
INSERT INTO `t2` VALUES (0,'READ');
2368
CREATE TABLE `t3` ( `id` int default NULL, `name` char(16) default NULL);
2517
CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
2369
2518
INSERT INTO `t3` VALUES (1,'fs');
2370
2519
select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
2371
2520
id name gid uid ident level
2372
2521
1 fs NULL NULL 0 READ
2373
2522
drop table t1,t2,t3;
2374
2523
CREATE TABLE t1 (
2375
acct_id int NOT NULL default '0',
2376
profile_id int default NULL,
2524
acct_id int(11) NOT NULL default '0',
2525
profile_id smallint(6) default NULL,
2377
2526
UNIQUE KEY t1$acct_id (acct_id),
2378
2527
KEY t1$profile_id (profile_id)
2380
2529
INSERT INTO t1 VALUES (132,17),(133,18);
2381
2530
CREATE TABLE t2 (
2382
profile_id int default NULL,
2383
queue_id int default NULL,
2384
seq int default NULL,
2531
profile_id smallint(6) default NULL,
2532
queue_id int(11) default NULL,
2533
seq int(11) default NULL,
2385
2534
KEY t2$queue_id (queue_id)
2387
2536
INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
2388
2537
CREATE TABLE t3 (
2389
id int NOT NULL default '0',
2390
qtype int default NULL,
2391
seq int default NULL,
2392
warn_lvl int default NULL,
2393
crit_lvl int default NULL,
2394
rr1 int NOT NULL default '0',
2395
rr2 int default NULL,
2396
default_queue int NOT NULL default '0',
2538
id int(11) NOT NULL default '0',
2539
qtype int(11) default NULL,
2540
seq int(11) default NULL,
2541
warn_lvl int(11) default NULL,
2542
crit_lvl int(11) default NULL,
2543
rr1 tinyint(4) NOT NULL default '0',
2544
rr2 int(11) default NULL,
2545
default_queue tinyint(4) NOT NULL default '0',
2397
2546
KEY t3$qtype (qtype),
3206
3407
EXPLAIN SELECT * FROM t1
3207
3408
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
3208
3409
id select_type table type possible_keys key key_len ref rows Extra
3209
1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL # Using intersect(idx2,idx1); Using where; Using index
3410
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where
3210
3411
EXPLAIN SELECT * FROM t1
3211
3412
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ;
3212
3413
id select_type table type possible_keys key key_len ref rows Extra
3213
1 SIMPLE t1 ref idx1,idx2 idx2 4 const # Using where
3414
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where
3214
3415
EXPLAIN SELECT * FROM t1
3215
3416
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL;
3216
3417
id select_type table type possible_keys key key_len ref rows Extra
3217
1 SIMPLE t1 ref idx1,idx2 idx2 4 const # Using where
3418
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where
3218
3419
DROP INDEX idx1 ON t1;
3219
3420
CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null);
3220
3421
EXPLAIN SELECT * FROM t1
3221
3422
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
3222
3423
id select_type table type possible_keys key key_len ref rows Extra
3223
1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index
3424
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where
3224
3425
EXPLAIN SELECT * FROM t1
3225
3426
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ;
3226
3427
id select_type table type possible_keys key key_len ref rows Extra
3227
1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index
3428
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where
3228
3429
EXPLAIN SELECT * FROM t1
3229
3430
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL;
3230
3431
id select_type table type possible_keys key key_len ref rows Extra
3231
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where
3432
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where
3232
3433
EXPLAIN SELECT * FROM t1
3233
3434
WHERE ID_better=1 AND ID1_with_null IS NULL AND
3234
3435
(ID2_with_null=1 OR ID2_with_null=2);
3235
3436
id select_type table type possible_keys key key_len ref rows Extra
3236
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where
3437
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where
3238
3439
CREATE TABLE t1 (a INT, ts TIMESTAMP, KEY ts(ts));
3239
3440
INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00");