1
00:00.160 --> 00:02.120
Let's solve another problem.

2
00:02.640 --> 00:04.520
So find mutual friends.

3
00:06.160 --> 00:08.080
So below is the problem statement.

4
00:08.720 --> 00:15.280
Given a social media follows table where each row indicates that one user follows another.

5
00:15.640 --> 00:21.640
Write a query to find all pairs of users who mutually follows each other.

6
00:22.400 --> 00:24.160
So let me.

7
00:26.280 --> 00:34.360
Copy and paste this data into the ChatGPT and let's see I am having below.

8
00:36.840 --> 00:38.080
Table structure.

9
00:40.240 --> 00:41.120
And data.

10
00:45.920 --> 00:46.160
Okay.

11
00:46.200 --> 00:50.120
It says that please go ahead and share your table structure.

12
00:57.480 --> 01:02.600
Okay I have shared my table structure and data with ChatGPT now.

13
01:03.180 --> 01:04.460
Uh, okay.

14
01:04.500 --> 01:10.420
It is already said that find all mutual follow pairs users who follow each other.

15
01:10.420 --> 01:12.780
And let's see what is our problem statement.

16
01:13.460 --> 01:18.340
Given a social media follows table where each row indicates that one user follows another.

17
01:19.100 --> 01:23.660
Write a query to find all pairs of users who mutually follow each other.

18
01:23.660 --> 01:25.260
So almost the same question, right?

19
01:25.260 --> 01:27.580
We can say so let me.

20
01:30.300 --> 01:38.340
So ChatGPT is that much of intelligent that it will generate the question from the data self data set

21
01:38.340 --> 01:41.860
by itself most of the time.

22
01:41.860 --> 01:42.380
Right.

23
01:42.660 --> 01:47.460
So let me still ask the ChatGPT about my problem statement.

24
01:50.140 --> 01:50.740
Okay.

25
01:52.460 --> 01:54.820
So it is a question related to self join.

26
01:54.820 --> 01:58.340
Or we can solve using another way as well.

27
01:58.580 --> 01:58.940
Okay.

28
01:58.980 --> 02:00.460
So it is given some code.

29
02:01.180 --> 02:04.460
So let me write it over here.

30
02:07.200 --> 02:14.880
And this is the solution we can say solution provided by the.

31
02:17.160 --> 02:17.840
ChatGPT.

32
02:17.880 --> 02:23.040
Right now let's see whether our solution and ChatGPT solution is same or not.

33
02:23.440 --> 02:25.600
So let me compare that one.

34
02:26.640 --> 02:27.720
Okay, fine.

35
02:27.920 --> 02:31.320
So our solution is one two and three four.

36
02:31.320 --> 02:32.000
Perfect.

37
02:32.440 --> 02:35.280
So both of the solution will be the same right.

38
02:35.680 --> 02:42.080
But see I have written the SQL query in more easier way right.

39
02:43.520 --> 02:52.440
So what I have done over here I have just used the same table two times but interchanging the column.

40
02:52.960 --> 02:55.000
And after that I have done the intersect.

41
02:55.000 --> 02:58.320
Right after that I have done the intersect.

42
02:58.400 --> 03:02.360
So see if you see this particular query.

43
03:02.720 --> 03:10.390
Now what I am doing wherever the following follow or ID is less than following ID that thing only I

44
03:10.390 --> 03:11.230
am selecting.

45
03:11.790 --> 03:17.190
So it will give me first first record and third record.

46
03:17.190 --> 03:17.550
Right.

47
03:17.550 --> 03:19.350
And that is what my requirement.

48
03:19.350 --> 03:25.470
Because if you see this two and one, so it is already the reverse of the one and two.

49
03:25.510 --> 03:25.950
Right.

50
03:26.470 --> 03:29.630
So that reverse thing we do not need to consider.

51
03:29.990 --> 03:33.430
So that is why I have written this additional condition over here.

52
03:33.430 --> 03:33.830
Right.

53
03:35.190 --> 03:41.670
But query provided by the ChatGPT is little difficult right to understand.

54
03:42.150 --> 03:48.630
So let me see whether any other solution has been provided by ChatGPT or not.

55
03:48.870 --> 03:49.310
Okay.

56
03:49.350 --> 03:50.510
It hasn't provided.

57
03:50.790 --> 03:59.350
So what I can do, uh, can you provide the solution?

58
04:01.470 --> 04:02.910
Using the inter.

59
04:06.550 --> 04:11.530
Intersect set Operators, right?

60
04:13.930 --> 04:14.450
Okay.

61
04:14.450 --> 04:22.730
Now let's see it as it is provided any solution with the intersect operator I think this one will be

62
04:22.730 --> 04:23.810
the wrong solution.

63
04:23.810 --> 04:24.810
Let me try.

64
04:27.730 --> 04:28.490
Let me.

65
04:31.050 --> 04:32.490
Try to execute now.

66
04:34.850 --> 04:35.170
Okay.

67
04:35.210 --> 04:36.450
This is a wrong solution.

68
04:36.450 --> 04:36.890
Right.

69
04:37.170 --> 04:41.210
So this is the limitation of ChatGPT as well.

70
04:43.970 --> 04:47.530
Not every time it will give the perfect solution.

71
04:47.890 --> 04:51.130
So we have to analyze the thing perfectly.

72
04:53.170 --> 04:59.370
That whether the solution provided by ChatGPT is correct or not, that we have to reverify.

73
04:59.410 --> 04:59.890
Right.

74
05:00.210 --> 05:02.450
And then only we can use it in our.

75
05:05.010 --> 05:11.050
Day to day life, we can say, right, so we will see the next, uh, question into the next lecture.

76
05:11.050 --> 05:11.650
Thank you.