security_man Posted February 22, 2012 Share Posted February 22, 2012 to me this looks logical, but obviously the like operator is the problem, i just dont know how to write it correctly, any help? i get the following error: #1054 - Unknown column '%tblhosting.domain%' in 'where clause' yes the columns and tables are correct - i just didnt think you wanted to look at my enter table structure SELECT * FROM `tblinvoiceitems`, `tblhosting` WHERE tblinvoiceitems.description LIKE `%tblhosting.domain%` Quote Link to comment https://forums.phpfreaks.com/topic/257579-need-help-with-like-in-where-clause-using-variable-from-a-second-table/ Share on other sites More sharing options...
requinix Posted February 23, 2012 Share Posted February 23, 2012 Wrong quotes. Backticks are for names of objects in the database (databases, tables, fields, etc.) while single- and double-quotes are for strings. LIKE "%tblhosting.domain%" But you don't want strings. How is this search supposed to work? Find all invoice items that have a description containing any hosting domain? Quote Link to comment https://forums.phpfreaks.com/topic/257579-need-help-with-like-in-where-clause-using-variable-from-a-second-table/#findComment-1320262 Share on other sites More sharing options...
security_man Posted February 23, 2012 Author Share Posted February 23, 2012 correct. i need to find all entries in my tblinvoice items that have the domain from tblhosting in the description. am i going about it totally wrong? Quote Link to comment https://forums.phpfreaks.com/topic/257579-need-help-with-like-in-where-clause-using-variable-from-a-second-table/#findComment-1320403 Share on other sites More sharing options...
ManiacDan Posted February 23, 2012 Share Posted February 23, 2012 It's going to be slow, but: WHERE tblinvoiceitems.description LIKE CONCAT('%', tblhosting.domain, '%') -Dan Quote Link to comment https://forums.phpfreaks.com/topic/257579-need-help-with-like-in-where-clause-using-variable-from-a-second-table/#findComment-1320405 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.