時,我有以下3個表MySQL查詢錯誤:加入3個表
,我需要設置一個HTML表,其中它顯示以下內容:
<tr class="bg-info">
<th>Med ID</th>
<th>Med Name</th>
<th>Med Expiry</th>
<th>Barcode</th>
<th>Number of Tablets received</th>
<th>Total Number of Pills received</th>
<th>Date Received</th>
<th>Pills distributed</th>
<th>Still (in tablets)</th>
<th>Still (in pills)</th>
</tr>
因此,我創建此SQL查詢:
select t1.med_id,
t3.med_name,
t1.med_expiry,
t1.med_barcode,
t1.med_tablet,
t1.med_pill,
t1.med_received,
sum(t2.given_quantity)
FROM med_pharmacy t1, consultation_med t2, medication t3 WHERE t1.med_pharmacy_id = t2.med_pharmacy_id AND t1.med_id=t3.med_id
AND t1.clinic_id='361'
而且我收到以下錯誤:
Error Code: 1140. In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'ncd.t1.med_id'; this is incompatible with sql_mode=only_full_group_by
然後你會得到錯誤的結果。好工作,@UlugToprak – fancyPants
閱讀更多關於['GROUP BY'](https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html) – axiac
那麼我該如何解決它? – droidnation