I have this SQL query that should be simple, but it doesn't seem to return any queries. I know there are records that have the word "amalgam" in there, but this query won't return any results. Any help would be appreciated. This query is for a search function that searchs for a keyword within Notes and Procedures and returns Category ID, etc.
SELECT DISTINCT tbl_Category.Category_ID, tbl_Category.Description, tbl_Category.Display_Order
FROM tbl_Category, tbl_Subcategory, tbl_ProcedureGroup, tbl_Procedure, tbl_Note, tbl_ProcedureNote
WHERE tbl_Category.Category_ID = tbl_Subcategory.Category_ID
AND tbl_Subcategory.Subcategory_ID = tbl_ProcedureGroup.Subcategory_ID
AND tbl_ProcedureGroup.Procedure_Group_ID = tbl_Procedure.Procedure_Group_ID
AND tbl_Procedure.Procedure_ID = tbl_ProcedureNote.Procedure_ID
AND tbl_ProcedureNote.Note_ID = tbl_Note.Note_ID
AND (tbl_Procedure.Description LIKE '%amalgam%' OR tbl_Note.Note LIKE '%amalgam%')
ORDER BY tbl_Category.Display_Order
If I rewrite the query like the following below, then it works, but I need it to search two tables, not just one:
SELECT DISTINCT tbl_Category.Category_ID, tbl_Category.Description, tbl_Category.Display_Order
FROM tbl_Category, tbl_Subcategory, tbl_ProcedureGroup, tbl_Procedure, tbl_Note, tbl_ProcedureNote
WHERE tbl_Category.Category_ID = tbl_Subcategory.Category_ID
AND tbl_Subcategory.Subcategory_ID = tbl_ProcedureGroup.Subcategory_ID
AND tbl_ProcedureGroup.Procedure_Group_ID = tbl_Procedure.Procedure_Group_ID
AND (tbl_Procedure.Description LIKE '%amalgam%')
ORDER BY tbl_Category.Display_Order
SELECT DISTINCT tbl_Category.Category_ID, tbl_Category.Description, tbl_Category.Display_Order
FROM tbl_Category, tbl_Subcategory, tbl_ProcedureGroup, tbl_Procedure, tbl_Note, tbl_ProcedureNote
WHERE tbl_Category.Category_ID = tbl_Subcategory.Category_ID
AND tbl_Subcategory.Subcategory_ID = tbl_ProcedureGroup.Subcategory_ID
AND tbl_ProcedureGroup.Procedure_Group_ID = tbl_Procedure.Procedure_Group_ID
AND tbl_Procedure.Procedure_ID = tbl_ProcedureNote.Procedure_ID
AND tbl_ProcedureNote.Note_ID = tbl_Note.Note_ID
AND (tbl_Procedure.Description LIKE '%amalgam%' OR tbl_Note.Note LIKE '%amalgam%')
ORDER BY tbl_Category.Display_Order
If I rewrite the query like the following below, then it works, but I need it to search two tables, not just one:
SELECT DISTINCT tbl_Category.Category_ID, tbl_Category.Description, tbl_Category.Display_Order
FROM tbl_Category, tbl_Subcategory, tbl_ProcedureGroup, tbl_Procedure, tbl_Note, tbl_ProcedureNote
WHERE tbl_Category.Category_ID = tbl_Subcategory.Category_ID
AND tbl_Subcategory.Subcategory_ID = tbl_ProcedureGroup.Subcategory_ID
AND tbl_ProcedureGroup.Procedure_Group_ID = tbl_Procedure.Procedure_Group_ID
AND (tbl_Procedure.Description LIKE '%amalgam%')
ORDER BY tbl_Category.Display_Order