Sql examination questions, how to write, ask for advice!

is like this, and the ultimate effect is to match the avatar address of the drink in the user table for each comment list

first, query out the table_1 (article comment table) article comment result set

then I found that these comments do not have user avatars, so I need to associate the table_2 (user table) of the query. In this place, the reply_user in the result set of the first comment query is associated with the username in the table_2 (user table).

the user avatar to be queried is in the avatar_link field of table_2 (user table)

then merge the list of comments and the corresponding avatar (each comment corresponds to a different user avatar)

solve the problem, sql is not good at learning

Mar.13,2021

--sql

SELECT a.*,b.avatar_link

FROM [dozhan_reply] a

INNER JOIN [dozhan_user] b ON a.reply_user = b.username

WHERE a.reply=69

related queries can't you? In addition, it is best to use the text to describe the problem. It looks convenient for


to describe the problem vaguely. The avatar address should be returned in the picture, and the text expression should be returned as well.
if the former, go to the top floor, make an association query, and then return avatar_link. For details, see https://bbs.csdn.net/topics/3.


is the most basic join query. Refer to SQL's four join queries

Note that the article is SQL Server syntax. You can find out how to write the syntax of MySQL .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b314cb-2bd79.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b314cb-2bd79.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?