Klausos Klausos
Klausos Klausos

Reputation: 16050

Select identical entries (LIKE)

SELECT F.* FROM FlightSchedule F, Aircrafts A 
WHERE F.aircraftType = A.aircraftType 
LIKE CONCAT('\"','%', F.aircraftType, '%','\"') AND F.flightNum_arr='3913';

SAMPLE CONTENT OF DB TABLES:

Table "Schedule"

aircraftType = "320"

Table "Aircrafts"

aircraftType = "A320"
aircraftType = "A330"

The expected result of the query is the selection of an entry that has aircraftType = "320" and flightNum_arr = "3913", because "320" is identical to "A320". The problem is that "320" and "A320" are not considered as identical in this query. How to fix the problem?

Upvotes: 0

Views: 98

Answers (1)

Barmar
Barmar

Reputation: 781096

Either use = for exact match, or LIKE for pattern match, but don't put both of them into the same expression. And you don't need to concat quotes into the LIKE pattern.

SELECT F.*
FROM FlightSchedule F
JOIN Aircrafts A
ON A.aircraftType LIKE CONCAT('%', F.aircraftType, '%')
WHERE F.flightNum_arr = '3913'

Upvotes: 3

Related Questions