Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Need help in resolving a query related to LIKE in mySQL Lite.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



I tried using LIKE statement as mentioned above (commented line) but since its not a constant field, how to we do it if not by this?
 
Saloon Keeper
Posts: 11882
253
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

I don't know what "mySQL LIte" is. I know about MySQL and I know about SQLite. I'm assuming you meant the latter.

I don't think SQLite has CONTAINS operator. What's wrong with just using LIKE?
 
Stephan van Hulst
Saloon Keeper
Posts: 11882
253
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the following:
 
Sakshi Narang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Welcome to CodeRanch!

I don't know what "mySQL LIte" is. I know about MySQL and I know about SQLite. I'm assuming you meant the latter.

I don't think SQLite has CONTAINS operator. What's wrong with just using LIKE?




Thanks, corrected the technology in description.
With just using like no data is added.
 
Stephan van Hulst
Saloon Keeper
Posts: 11882
253
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The query I provided does nothing?

Maybe you can show us some example data from your tables, and tell us what output you are expecting.
 
Marshal
Posts: 25436
65
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on my travel booking experience, I guess that the booking reference might contain the invoice number, whereas the SQL we're talking about looks for invoice numbers which contain the booking reference. But that's a guess, like Stephan says it would help to see actual data.
 
Sakshi Narang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Try the following:



This was giving more data rather than filtering it,
Din't have much time to look into the reason.
Maybe because bookingRef is a list of different bookings and invoice is another list of different invoices containing booking references in it.
Ended up making a small utility for the same in java.
But, your code dint break.

"/*inputInvoice
           abcd123
           efgh456
           ijkl789
           mnop1012*/
   /*inputBookingRef
       456
       789*/
result expect was:
   /*resultInvoice, resultBookingRef
   efgh456,456
   ijkl789,789
    */"
 
Stephan van Hulst
Saloon Keeper
Posts: 11882
253
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what was the actual result?
 
Sakshi Narang
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:So what was the actual result?



Input is two tables InputInvoice and inputBookingRef:
inputInvoice
abcd123
efgh456
ijkl789
mnop1012


inputBookingRef
456
789


Output should be:
resultInvoiceresultBookingRef
efgh456456
ijkl789789


 
Sheriff
Posts: 7052
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From what I'm understanding, the WHERE clause should look like this:
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic