Ask questions about the statements of two MYSQL tables
$sql = "SELECT a.id,a.cover,a.name,a.name2,b.id,b.likes,b.month FROM dede_aiyunma_user AS a,dede_aiyunma_thing AS b WHERE a.id=b.id order by a.id desc";$dsql->Execute('me',$sql);while($row = $dsql->GetArray('me')){$uid = $row['id'];$cover = $row['cover'];$fname = $row['name'];$mname = $row['name2'];$like = $row['likes'];}
You can view the data in Table a and Table B. Now, the B. likes field is required to be displayed according to the B. month field. how can this statement be changed?
If it becomes WHERE. id = B. id and B. month = $ month order by. id desc, which is the condition of two tables, so that where B. month = $ month only applies to Table B. How do I write?
Reply to discussion (solution)
B. month = $ month is used only for Table B.
B. month = $ month is used only for Table B.
Hello, I feel like a reply
$sql = "SELECT a.id,a.cover,a.name,a.name2,b.id,b.likes,b.month FROM dede_aiyunma_user AS a,dede_aiyunma_thing AS b WHERE a.id=b.id and b.month= $month order by a.id desc";$dsql->Execute('me',$sql);while($row = $dsql->GetArray('me')){$uid = $row['id'];$cover = $row['cover'];$fname = $row['name'];$mname = $row['name2'];$like = $row['likes'];}
After the B. month = $ month condition is added, the data in table A ($ uid $ cover $ fname $ mname) is not displayed. the requirement is that $ like is changed according to $ month.
Your connection condition is a. id = B. id
Your filtering condition is B. month = $ month
If no result is returned, no matching record exists in B.
So, is your B. month numeric?
Thank you for your patience.
Your connection condition is a. id = B. id
Your filtering condition is B. month = $ month
If no result is returned, no matching record exists in B.
So, is your B. month numeric?
Well, B. month is a numeric int.
Still don't understand. B does not have a qualified record, but the variables in a cannot output data.
Now, my goal is to query and output the data of Table a. Table B only returns 0 if the likes field with month as the condition is not found.
I don't know whether it's my code or SQL, so it's hard for beginners.
In this case, you can write it in the back and sort it by a. id.
If you want to follow B. month = $ month, you can only write another sentence.