Jump to content
php.lv forumi

Recommended Posts

Posted

posts tabula

id | post_id | user_id | text

--------------------------------

1 | 0 | 1 | bla bla

2 | 0 | 2 | bla bla bla

3 | 1 | 5 | bla bla bla bla bla bla

4 | 0 | 6 | bla bla

5 | 2 | 5 | bla bla bla

6 | 0 | 2 | bla bla bla bla bla

7 | 0 | 1 | bla bla bla bla bla bla bla

8 | 0 | 4 | bla bla bla

9 | 0 | 4 | bla bla

 

uzlikts, lai rādā visus ierakstus ORDER BY id DESC

 

kā ir jāselekto, lai ja post_id ir vienāds ar mana posta id tad viņu nerāda, ja pieņemsim mans user_id = 1 un id = 1, gribu panākt, lai nerāda id = 3, jo viņa post_id = 1 (manu posta id)

 

ceru, ka sapratāt, paldies jau iepriekš

Posted

Varētu būt kaut kā šādi

SELECT t1.* FROM tabula t1
LEFT OUTER JOIN t2 on t1.id = t2.post_Id

ORDER BY t1.id DESC

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...