user1269625
user1269625

Reputation: 3209

PHP inner join on id issue

I have this script here

select distinct 
FirstName, 
LastName, 
table_2.status, 
'Shop' as receiver
from table_1
inner join table_2 on table_1.key_2 = table_2.'SHOP-'id
order by FirstName, LastName

the key_2 field has ids like SHOP-121 and the id in table 2 would just be the number 121.

How would I remove the SHOP- from key_2 or add SHOP- to id?

Upvotes: 0

Views: 67

Answers (1)

John Woo
John Woo

Reputation: 263693

use CONCAT

table_1.key_2 = CONCAT('SHOP-', table_2.id)

Remember that this will perform full table scan causing it to be slow on large database.

Upvotes: 5

Related Questions