Home > database >  SQL, column and column B one-to-one correspondence, if the column corresponding to the column B mult
SQL, column and column B one-to-one correspondence, if the column corresponding to the column B mult

Time:04-30

As shown, by querying the above-mentioned content in the following table results:

CodePudding user response:

Select * from tbale where id="A"

CodePudding user response:

SELECT *
FROM the TABLE A
WHERE the EXISTS (SELECT 1 FROM the TABLE WHERE Anderson, D=ID AND A.T D<> TD)

CodePudding user response:

reference 1st floor qq_35147215 response:
select * from tbale where id="A"

Isn't this meaning, is not A separate query ID value for A data,
Column A and column in the table B one-to-one correspondence, namely each ID may correspond to an IT, also may correspond to multiple IT, corresponding to the multiple pick out IT,

CodePudding user response:

refer to the second floor RINK_1 response:
SELECT *
FROM the TABLE A
WHERE the EXISTS (SELECT 1 FROM the TABLE WHERE Anderson, D=ID AND A.T D<> TD)


Don't look for, A value of 1, but there are also likely to G, H, I, such as ID, the corresponding value is 1,

CodePudding user response:

Above attached figure sample size is too small, no problem, then figure: a

CodePudding user response:

reference 4 floor hzgs2020 response:
Quote: refer to the second floor RINK_1 response:
SELECT *
FROM the TABLE A
WHERE the EXISTS (SELECT 1 FROM the TABLE WHERE Anderson, D=ID AND A.T D<> TD)


Don't look for, A value of 1, but there are also likely to G, H, I, such as ID, the corresponding value is 1,


You take the example in figure behind you try

CodePudding user response:

Select * from test where id in
(
Select the ID from the test
Group by ID
Having a count (distinct TD) & gt; 1
)