continue...
Hi
I don't understand joins very well but in this case I'm confused even more...
I have three tables: user, anonym, post
Table: user
id|name|email |points
1 |Adam|A@A.xx|100
2 |Lacy|L@L.xx|16
3 |Cody|C@C.xx|1720
Table: anonym
id|name|
1 |Rose
Table: post
id|text|author_type|author_id
1 |aaaa|R |1
2 |bbbb|R |3
3 |cccc|A |1
Now I want to retrive data about post on specific id and data(which sometimes is stored in table "user" and sometimes in table 'anonym") about author of the post.
Let's take post with ID=3, query should return
post.id=3
post.text=cccc
post.author_type=A (A stands for anonym)
post.author_id=1
anonym.id=1
anonym.name=Rose
with ID=2
post.id=2
post.text=bbbb
post.author_type=R (R stands for registered user)
post.author_id=1
user.id=1
user.name=Cody
user.email=C@C.xx
user.points=1720
I tried various queries which I could come across the last one look'd something like this:
SELECT * FROM post,user,anonym WHERE post.id=1 AND IF(post.author_type='R', SELECT * FROM user ..., SELECT * FROM anonym...)
but of course it failed since even syntax is incorrect