There should be only two results, but why is it repeated three times?

eunnnnn1996
select a.m_num,a.filename,a.title,a.price,a.stock
from newboard a , cart b
where a.m_num = b.m_num and a.board_num = ANY(select board_num from cart where m_num = '82');

The result

FIELD1 FIELD2 FIELD3 FIELD4 FIELD5
82 NO1.png car 39000 1
82 0 0
82 NO1.png car 39000 1
82 0 0
82 NO1.png car 39000 1

Why is it repeating?

Ameena Bano

Since inner join is working as Cartesian Product. To get distinct rows either use distinct keyword after select or use group by.

Example:

select a.m_num,a.filename,a.title,a.price,a.stock
from newboard a , cart b
where a.m_num = b.m_num 
and a.board_num = ANY(select board_num from cart where m_num = '82')
 group by a.m_num,a.filename,a.title,a.price,a.stock;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why does assignment to reference (:=) give different results when running code say two or three times within data.table format?

PHP While loop only works for first two of three results?

A button should be clicked only two times in a minute, how should I check it?

Why does this ask for three inputs when there are only two scanf calls?

Why do only two of these three addKeyCommand 's work

Why is dependency repeated many times in Webpack artifact?

Why a SELECT result is repeated 4 times?

Why is the colored ribbon repeated multiple times in the output

Regex to detect if character is repeated more than three times

Regex: Find the lines on which the number 20 is repeated three times

Why do repeated values appear in SQL results

Why a function in react is getting called three times when I am calling only one time

Results in for loop repeated too many times - remove duplicates JS

Why does not 'while(csv.Read())' work two / three times in CsvHelper?

Why do some identical POST requests take two or three times longer than others?

Why JS functions are called only once in Karate framework if should several times?

Split a string only two times

for loop is running two times only

Sum only for repeated values in two another columns

Change Array Elements Only Three Times, Repeat

Puppeteer only runs three times on Heroku

Python regex: match only if pattern is repeated n number of times

return array with elements that can be repeated only N times

Splitting a sequence where a character is repeated exactly two times

Why useEffect running two times?

should iuse WidgetsFlutterBinding.ensureInitialized(); two times?

Why labels are mentioned three times in a single deployment

Why is my udev rule executed three times

Why is my python script executed three times?