Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
join1_databaser [2016-10-28 13:07] Joakim Forsgren |
join1_databaser [2018-10-05 14:33] Joakim Forsgren |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Databaser + enkla JOIN ====== | ====== Databaser + enkla JOIN ====== | ||
+ | <code sql> | ||
+ | # Eventuellt måste man köra detta kommando för att få GROUP BY att fungera. | ||
+ | # Får ni felet ...incompatible with sql_mode=only_full_group_by... kör kommandot nedan | ||
+ | SET sql_mode=(SELECT REPLACE(@@sql_mode, | ||
+ | </ | ||
Gå igenom '' | Gå igenom '' | ||
- | < | + | < |
- | select join_users.*, | + | # ex från genomgång |
+ | select join_users.*, | ||
+ | from join_users | ||
+ | left join join_items | ||
+ | on join_users.user_id=join_items.user_id | ||
+ | where join_users.user_id > 25 | ||
+ | group by join_users.user_id | ||
+ | having antal=0 | ||
+ | order by antal desc; | ||
</ | </ | ||