0

I understand that this question is both vague and broad. But I'm in need of a correlated subquery. I'm having great difficulty in understanding the difference between the two and I'm wondering if the query below would be uncorrelated or correlated.

SELECT PlayerName , DatOfBirth, FIDERating ,FIDETitle,player.ClubName
FROM player
WHERE player.ClubName =(
    SELECT club.ClubName
FROM club  WHERE clubname.ClubName='Link') 

If uncorrelated any help in understanding how to get a correlated query from this would be very much appreciated

Here is a list of the tables I'm trying to do the query on:

CREATE TABLE chessleague.table2 ( PlayerName VARCHAR(50) NOT NULL , DateOfBirth VARCHAR(10) NOT NULL , FIDERating INT NOT NULL , FIDETitle VARCHAR(22), ClubName VARCHAR(50) NOT NULL, PRIMARY KEY (PlayerName),FOREIGN KEY (ClubName) REFERENCES table1(ClubName);

CREATE TABLE chessleague.table1 ( ClubName VARCHAR(50) NOT NULL , Address VARCHAR(100) NOT NULL , DateFormed VARCHAR(10) NOT NULL , PRIMARY KEY (ClubName);

enter image description here

enter image description here

The requirement is very vague and only requires me to have one correlated and one uncorrelated.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • That subquery would be uncorrelated. corelated uses a column reference from a table outside the subquery.(in this case table player) – Raymond Nijland Nov 15 '17 at 19:08
  • 1
    Possible duplicate of [Difference between Subquery and Correlated Subquery](https://stackoverflow.com/questions/17268848/difference-between-subquery-and-correlated-subquery) – krokodilko Nov 15 '17 at 20:14
  • You'll need to share some sample data and your desired results. I could make this correlated but there is near 0% chance it will match your requirements since "I need this to be correlated" is too broad. I'm assuming this is a homework assignment; if so, just paste the question and relevant details here and be honest about it. We can help guide you to the answer. Lastly, as it's written your WHERE clause could just be rewritten to `WHERE player.clubname = 'Link'` – JNevill Nov 15 '17 at 21:06
  • @JNevill I will share more data in the morning If you're still able to help then. I know its broad and your correct its an assignment for a database in MySQL in which I was given data and had to build a database, java program and a list of queries of which was a correlated subquery. So really I'm just looking somehow to get one as I've never encountered them before – John McCullough Nov 16 '17 at 00:45

0 Answers0