The data table activity contains fields such as ac_idac_titleopenid and ap_idac_id in the apply field) openid and other fields now need to first find out that the application has a field that matches the user's openid, and then query the ac_id in the apply table... the data table activity contains fields such as ac_id ac_title openid.
The data table apply contains fields such as ap_id ac_id (ac_id in the activity table) openid.
Now we need to first check that the "apply" field matches the user's openid, and then query the dataset where the "ac_id" in the "apply" table is equal to the "ac_id" in the activity table.
query("select * from activity,apply where apply.ac_id=activity.ac_id order by ap_id desc");
Such a statement can only query the dataset where the "ac_id" in the "apply" table is equal to the "ac_id" in the "activity" table, but does not know how to find the data where the "openid" in the "apply" table is equal to the user's openid. the great god proposed a solution. The younger brother is a beginner.
Reply content:
The data table activity contains fields such as ac_id ac_title openid.
The data table apply contains fields such as ap_id ac_id (ac_id in the activity table) openid.
Now we need to first check that the "apply" field matches the user's openid, and then query the dataset where the "ac_id" in the "apply" table is equal to the "ac_id" in the activity table.
query("select * from activity,apply where apply.ac_id=activity.ac_id order by ap_id desc");
Such a statement can only query the dataset where the "ac_id" in the "apply" table is equal to the "ac_id" in the "activity" table, but does not know how to find the data where the "openid" in the "apply" table is equal to the user's openid. the great god proposed a solution. The younger brother is a beginner.
You only need to add the openid condition to the SQL statement, that is, add and openid = 'xxx' as follows'
select * from activity,apply where apply.ac_id=activity.ac_id and apply.openid='xxx' order by ap_id desc
Assume that the openid of the user to be searched is 2, which means:
1. Search openid = 2 from the activity of the data table as the Dataset 1.
2. for data in Dataset 1, find the data of apply. ac_id = Dataset 1. ac_id in the apply data table?
How about left connection?
Select * from activity as ac left join apply as ap on ac. ac_id = ap. ac_id where openid = "xxxxx"