New answers tagged

-1

No one pointed out the actual problem with the Bad code so: You need to name the inner SELECT's output using AS some_name SELECT COUNT(ip_address) FROM ( SELECT DISTINCT ip_address FROM `ports` WHERE status IS TRUE ) AS some_name As mentioned already, best is: SELECT COUNT(DISTINCT ip_address) FROM `ports`; Why? See: https://stackoverflow.com/questions/...


-2

my trick is, make temporary table with field category and units then u make schedule at night to counting it n save to your temporary table, then ur just read that table with just 12 row in it, very faster, but ur count H-1, u need liitle trick againt to add current day ...


0

You may use union all to avoid sorting mysql> select id from ( -> SELECT u.id -> FROM user u -> LEFT JOIN translation_revision t1 -> ON u.id = t1.translator_id ->union all -> SELECT u.id -> FROM user u -> LEFT JOIN translation_revision t2 -> ...


2

Instead of doing 3 separate joins, you could accomplish the same thing by simply using an OR clause (the execution time seems to be ~1-2ms): SELECT DISTINCT u.id FROM user u JOIN translation_revision t1 ON u.id = t1.translator_id OR u.id = t1.proofreader_id OR u.id = t1.reviewer_id GROUP BY u.id LIMIT 30 Other ideas would be to denormalize your data ...


0

Maybe simply SELECT DISTINCT u.id FROM user u JOIN translation_revision t ON u.id IN (t.translator_id, t.proofreader_id, t.reviewer_id) ?


Top 50 recent answers are included