cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA SQL Query using wildcard

0 Kudos

Hi All,

I have to compare data of two tables using wildcard.

Data should be there in first table but not in second table.

Common field between both the tables are

Rollno = batch

My data is in below format:

Table-1 Table-2

Rollno Batch

A:123 123

B:423 C:657

Expected output: B:423

My problem is how to link these two tables on the basis of like operator.

Please suggest me an answer to solve this query.

Thanks in advance!!!

pfefferf
Active Contributor
0 Kudos

Hi, why do you need to use LIKE? Is your data different than you should in your example?

Jörg_Brandeis
Contributor
0 Kudos

You can see from the different answers that your actual question was not understood. This is a pity, because we invest our time for your support. Please write precisely what the problem is. With screenshots, complete examples, your own clearly formatted source code. Then helping will be fun and will bring you the desired result.

Accepted Solutions (0)

Answers (2)

Answers (2)

ThorstenHoefer
Active Contributor
0 Kudos

Hi Priya,

I'm not sure, if you want to compare A:123 with 123 ?

in this case, you can use instr.

String Functions - SAP Help Portal

where instr( a.rollno , b.batch ) > 0)

select a.rollno
from table_1 as a
where not exists (
select 1
from table_2 as b
 where b.batch = a.rollno )
Jörg_Brandeis
Contributor
0 Kudos

Hi Priya,

why do you want to use a LIKE operator?

You can use an EXISTS predicate in the WHERE clause to select all data.

Or you do an LEFT OUTER JOIN and filter on NULL values with the IS NULL predicate.

Regards,
Jörg