Mysql
 sql >> Baza danych >  >> RDS >> Mysql

Wymagane pojedyncze zapytanie do pobrania danych z tabel

1)all details from user_message

SELECT * FROM user_messages WHERE userid = <userID> AND messageid = <messageID>;

2)last 10 comments related to messageid in ascending order from comments table (one message can have multiple comments)which includes comment_id ,comment, comment_date,and details of commented_by(fname,lname,small_pic_path).

SELECT a.comment_id, a.comment, a.comment_date, b.fname || b.lname || c.small_pic_path "Commented by" 
FROM comments a, smusers b, profile_pic c, user_messages d
WHERE d.messageid = <messageID>
AND d.userid = b.id
AND b.id = c.userid
ORDER BY comment_date
LIMIT 0, 10;

3)all small_pic_path from post_images(one message can have multiple images),

SELECT small_pic_path
FROM post_images;

4)total likes from like table,

SELECT * FROM likes;

5)all details (smsusers.*,profile_pic.*) of sentby

You have not posted the structure of sentby


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Wyszukiwanie pełnotekstowe MYSQL i LIKE

  2. Tablice kopii zapasowych doktryny

  3. 1064, Wystąpił błąd w składni SQL;... Python MySQL

  4. MySQL/SQL pobiera pierwsze 40 znaków pola tekstowego?

  5. Tabele siatkówki MySQL