MySQL LIKE query

(Asdar) #1

I have the table wp_ftp_orders_log with the column CustomerName with name and surname.
I would search only the surname and get result value CustomerName.
How could I do This?

(Karen Barker) #2

Hi @Asdar,

Your search will need to be along the lines of:

SELECT column1, column2, …
FROM table_name
WHERE CustomerName LIKE ‘%Surname’;

(Asdar) #3

Thank you for your reply @KarenBarker,
I have created a mysql query with:
SELECT CustomerName FROM wp_ftp_orders_log WHERE CustomerName LIKE ‘%:surname’
declared the value for surname (castellone) but unfortunately I have received this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘castellone’’’ at line 1
trying the same syntax on phpmyadmin:
SELECT CustomerName FROM wp_ftp_orders_log WHERE CustomerName LIKE ‘%castellone’
works!
may the combination of %: cause error?

(Karen Barker) #4

Hi there,

If you look in your interaction logs for the query action you should be able to see the exact query that gets sent to the database. Hopefully this will show how we are formatting the query which should enable you to see where the issue is. If you’re still having trouble please can you share a screen shot of the logs to support@flowxo.com.

Thanks. :slight_smile:

(Fabio) #5

I am having the exact same issue and cannot find any documentation detailing how to use a LIKE query using the placeholder, it seems like it is trying to escape the % and this causes the query to fail.

(Karen Barker) #6

Hi,

It looks like you’re using the Data fields to pass the correct value into the query. If so you can add the % to the value of the Data field such as:

This will then pass the value ‘%answer’ automatically into the query and it should run successfully. The query itself will then look like this:

SELECT column1, column2 FROM table_name WHERE column3 LIKE :data

1 Like
Data from MYSQL to Dropdown
(Fabio) #7

Awesome works perfectly, thank you very much