0

I am using sqlite in one my ios project where among other columns there are two columns. one has country code for mobile dialing like +880 and other column has rest of the mobile number like 1912353697. Now i want to join values from these two columns and compare the result value against like +8801912353697 and if matches pull the corresponding name value in that table . what would be the right query. I have tried like SELECT name FROM CONTACT_LIST WHERE (SELECT mblDc || mbl FROM CONTACT_LIST) = "+8801617634317" ; but that does not work .

A help would be appreciated.

sujat
  • 287
  • 2
  • 16

2 Answers2

1

Try:

SELECT name FROM CONTACT_LIST 
WHERE mblDc || mbl = "+8801617634317";

From SQLite documentation: The || operator is "concatenate" - it joins together the two strings of its operands.

MinhD
  • 1,790
  • 11
  • 14
0

please check How to concatenate strings with padding in sqlite

using substr function we can do the job and the query should be like

SELECT name FROM CONTACT_LIST WHERE  (mblDc || mbl) = "+8801617634317" ;
Community
  • 1
  • 1
Swarna Sekhar Dhar
  • 550
  • 1
  • 8
  • 25