Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
Can someone help in resolving one of following commented lines please?
I tried with LIKE as well as CONTAINS.
Got no result with like but the values are there.

Also, CONTAINS doesn't seem to work in mySQL LIte.

SQL
<pre>CREATE TABLE PxpAsPerPolarBookings AS SELECT pxp.invoice , PolarCruiseBrandPax.bookingRef 
From pxp, PolarCruiseBrandPaxFile2 
where 
//pxp.invoice CONTAINS PolarCruiseBrandPaxFile2.bookingRef;
//OR
//pxp.invoice like '%'+ PolarCruiseBrandPaxFile2.bookingRef +'%';


What I have tried:

I tried using like statement but since its not a constant field, how to we do it if not this:
pxp.invoice like '%'+ PolarCruiseBrandPaxFile2.bookingRef +'%';
Posted
Updated 9-Apr-20 22:52pm
Comments
#realJSOP 10-Apr-20 4:35am    
What's the error you're getting? "Doesn't seem to work doesn't tell us anything at all.
Richard MacCutchan 10-Apr-20 4:43am    
Why are the last three lines commented out?
#realJSOP 10-Apr-20 6:25am    
Probably because they "don't work".

1 solution

One reason for not returning any data could be if the column is case sensitive. You can try the following
SQL
SELECT pxp.invoice, 
       p2.bookingRef 
FROM pxp, 
     PolarCruiseBrandPaxFile2 p2
WHERE pxp.invoice COLLATE UTF8_GENERAL_CI LIKE '%' + p2.bookingRef + '%';
 
Share this answer
 
Comments
Maciej Los 10-Apr-20 5:55am    
5ed!
Wendelius 10-Apr-20 6:29am    
Thanks!
#realJSOP 10-Apr-20 6:27am    
But LIKE eliminates the need to be concerned with case sensitivity (or it does in SQL Server).
Wendelius 10-Apr-20 6:29am    
Depends on the selected collation, also in SQL Server. Also note that it is not operator specific, the same applies to equality etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900