Forgive me if this question has already been asked, but… I’m trying to select data from 2 different tables in a database and count all the data in one table that is equal to the data in the second table if that makes sense? Below is the code I am trying to use
$select = "SELECT * FROM client_id, clientid, COUNT(client_id) FROM enquiry, check_s WHERE client_id = clientid";
Your query appears to be syntactically wrong.
What you can try is to join the two tables on a primary key(id?) and any other fields you’re trying to match. The basic syntax would be like this:
If you’re looking for an exact data match, you may have to join the tables based on all fields(in the
ONclause in the above query).Edit:
Now that you’ve explained it, you can try this:
Again, if you need to compare more fields, just include them in the
ONclause, and set conditions in theWHEREclause.