i am bit confuse in to getting the result into the two tables, i know it is simple but not getting any clue.. here is my query the gives me the result, but when i am using the group by
then it's just giving me the result of one line even the actual result in database is (300, 500) because i am fetching the result through the lead_id
which is common in both tables..
SELECT inv.amount, crmd.computers, crmd.product_id, crmd.pc_opti
FROM invoice AS inv, lead_crm_data AS crmd
WHERE inv.lead_id = '310'
AND crmd.lead_id = '310'
GROUP BY inv.lead_id
here is the result of the given query..
amount computers product_id pc_opti
300 2 7, 6 2
300 3 7, 6 3
540 2 7, 6 2
540 3 7, 6 3
result with GROUP BY
300 2 7, 6 2
Desired REsult
300 2 7, 6 2
540 3 7, 6 3
Try this:
SELECT inv.amount, crmd.computers, crmd.product_id, crmd.pc_opti
FROM invoice AS inv, lead_crm_data AS crmd
WHERE inv.lead_id = '310'
AND crmd.lead_id = '310'
GROUP BY inv.amount
You could use a better (IMHO) syntax:
SELECT inv.amount, crmd.computers, crmd.product_id, crmd.pc_opti
FROM invoice AS inv INNER JOIN lead_crm_data AS crmd
ON inv.lead_id = crmd.lead_id
AND inv.lead_id = '310'
GROUP BY inv.amount
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.