I have a QUERY which is like
SELECT COUNT(*) as cnt
FROM tbl_docatrtypegroupdoctype,
tbl_doctype,
tbl_docatrtypegroup
WHERE 1=1
AND
(tbl_doctype.doctype_name like '%Payment%'
OR tbl_doctype.doctype_name like'% Payment'
OR tbl_doctype.doctype_name like ' Payment%' )
LIMIT 1
Now in the above query I need to count the number of records in table “tbl_docatrtypegroupdoctype” under the conditons given in where clause, whenever i execute the query, I get 77 count, but actual count in DB is 12.
What could be the problem with this query and how can I rectify it?
Ant help will be appriciated
Thanks
You need to specify your join conditions. What happens if you don’t is a cross product which is not what you want.
Alternatively the JOIN conditions can be spefified in the WHERE clause.
In the where clause:
The fields that you join on must be semantically related in some way of course.