joe1986 Posted August 27, 2009 Share Posted August 27, 2009 Hi there, Im using mysql Ver 14.12 Distrib 5.0.75 and im having a problem writing a specific statement within a php page. The code is as follows: $q = "SELECT c.id_case, c.title, c.status, c.date_creation, fu.*, a.name_first, a.name_middle, a.name_last FROM lcm_case as c, lcm_followup as fu, lcm_author as a, lcm_case_author as ca WHERE c.id_case=fu.id_case AND fu.id_author=a.id_author AND ca.id_case=fu.id_case AND ca.id_author=fu.id_author"; if (strlen($find_followup_string)>1) { // Add search criteria $q = "SELECT * FROM lcm_followup WHERE ((id_followup LIKE '%$find_followup_string%') OR (type LIKE '%$find_followup_string%') OR (description LIKE '%$find_followup_string%')) AND c.id_case=fu.id_case AND fu.id_author=a.id_author AND ca.id_case=fu.id_case AND ca.id_author=fu.id_author"; Sorry, there is a small amount of PHP code there, but just to demonstrate what I need. Simply, I have one SQL statement which is executed if there is no search term in a PHP search box (This runs fine), and another which is supposed to run when there is a search term present. This runs fine if I dont include the AND statements but I dont get the results I need from the other two tables. The error message I am getting is: Error: Error in SQL database query. « Unknown column 'c.id_case' in 'where clause' » I am using 3 tables named, lcm_followup, lcm_case and lcm_author Can anybody help? Quote Link to comment https://forums.phpfreaks.com/topic/172130-mysql-statement-error/ Share on other sites More sharing options...
joe1986 Posted August 27, 2009 Author Share Posted August 27, 2009 I have just realised one of the problems. The two other tables I am trying to access are not included as part of the SELECT, however I have included these tables but MySQL still throws an error. Quote Link to comment https://forums.phpfreaks.com/topic/172130-mysql-statement-error/#findComment-907566 Share on other sites More sharing options...
fenway Posted September 7, 2009 Share Posted September 7, 2009 We'll need to see the actual mysql query, and the relevant table structures. Quote Link to comment https://forums.phpfreaks.com/topic/172130-mysql-statement-error/#findComment-914125 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.