-1

I have tried with the query SELECT * FROM table_a WHERE id = 1987 AND worklist LIKE "%'worklistConfig':'clientLevel'%";

It is working in my sql & powershell. but i need to execute this is procedure via powershell. i have tried with the below query.

SELECT * \r\nFROM ch_form_worklist WHERE id = 1987 AND worklist LIKE "%'worklistConfig':'clientLevel'%";

You can see the \r\n in the query. So how to apply the LIKE statement in the query "%'worklistConfig':'clientLevel'%";

I have re-write with the below query,

SELECT * \r\nFROM ch_form_worklist WHERE id = 1987 AND worklist LIKE ''%worklistConfig:clientLevel%'';

is it ok or need to modify the like statement?

Noufal netspective
  • 101
  • 1
  • 1
  • 8
  • 1
    What happens if you execute the above query in powershell? Do you get an error message or do you get the expected output? If it is the latter, then the statement is ok. If it is the former, then you need to modify the statement. – Shadow Nov 24 '21 at 08:24
  • Think about [creating a minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). Is there an error ? What is the code around that that could be relevant ? ... Just like that, I'd say your query is bad because it includes `\r\n` which is something MySQL won't care about (I'd think). If you want to write your query on multiple line in Powershell, then use a multiline string instead. – Sage Pourpre Nov 24 '21 at 08:55

1 Answers1

0

Try wrapping your original statement in a string literal, like this:

$sqlQuery = @"
    SELECT * FROM table_a 
    WHERE id = 1987 
    AND worklist LIKE "%'worklistConfig':'clientLevel'%"
"@
nimizen
  • 3,345
  • 2
  • 23
  • 34