My database and SQL:
http://sqlfiddle.com/#!9/ebddb/1/0
Problem:It returns duplicates with incorrect data in name-column when in notchtype-table
less than 7 entries
My question is:Why does he return duplicates and how to prevent them?
Expected Result:This script shows the expected result: http://sqlfiddle.com/#!9/22660/1
As a result of this, the only thing added more than in my actual database and SQL is 2 entries in notchtype-table
Therefore, columns id, notchidand numbermust be unique in the returned string.
. SQL MariaDB 10.1.9 -
:- , ,
notchtype 7 , , "". null null.size -column , LEFT JOINnotches.notchdescr "" notchtype.notchtypeid namenotches.notchsize "" notchsize.notchsizeid size
:INNER JOIN, ,DISTINCT, name - ,GROUP BY, name -column
/ Piyush Guptaββstrong >, MySQL 5.7:
SELECT
notches.id,
notches.notchid,
notches.number,
notches.xcoord,
notches.ycoord,
notches.mapid,
notches.location,
notches.date,
notches.price,
notches.invoiced,
notchsize.size AS notchsize,
notchtype.name AS notchdescr
FROM
notches
LEFT JOIN
notchtype ON
notches.notchdescr = notchtype.notchtypeid
LEFT JOIN
notchsize ON
notches.notchsize = notchsize.notchsizeid
WHERE
notches.del = 0
AND
notches.projectid = '2016032411364363055'
GROUP BY notches.id, notches.notchid, notches.number
ORDER BY notches.number ASC
:

!LEFT JOIN VARCHAR= BIGINT . . .