Need help with set-up of custom query using $_GET variables for use in search fields

Hello,

I’m trying to set-up a custom query that joins fields from two tables using the query below, however I get a syntax error with the $_GET variables. Could you please help me with the correct syntax?

SELECT * FROM line JOIN expense ON line.expense_id = expense.id WHERE line.description LIKE ‘$_GET[‘description’}’ AND line.part_number LIKE ‘$_GET[‘catalog’}’ AND expense.company LIKE ‘$_GET[‘company’}’ AND expense.requestor LIKE ‘$_GET[‘requester’}’ AND expense.number LIKE ‘$_GET[‘number’}’ ORDER BY expense.date DESC

Thanks,
Cynthia

Hello,
Please check the docs about custom queries:

Teodor,

I did refer to the tutorial you suggested, however it does not provide enough specific information to help me with the correct syntax. I did finally figure it out. The query is below, for those who might have the same issue.

SELECT * FROM line JOIN expense ON line.expense_id = expense.id WHERE line.description LIKE :P1 /{{$_GET.description}}/ AND line.part_number LIKE :P2 /{{$_GET.catalog}}/ …

Correction to the sql query …

I guess astericks, slashes, and brackets are automatically removed when posting in the forum. The correct syntax is LIKE :P1 (slash)(asterick)(2 open brackets)$_GET.variable_name(2 close brackets)(asterick)(slash).