user1274113
user1274113

Reputation: 446

Make ID negative in a JOIN

I have this query

SELECT t1.*, t2.* FROM table1 AS t1 LEFT JOIN table2 AS t2 ON t2.id = t1.id

I want to consider "t1.id" (INT type) as negative so basically i simply have to add "-" before "320". I tryed with something like this with no success:

t2.id = 't1.'-'id'

How can i make it?

Upvotes: 2

Views: 55

Answers (2)

Derek
Derek

Reputation: 23228

Multiply by -1

t2.id = -1 * t1.id

Upvotes: 2

hek2mgl
hek2mgl

Reputation: 157967

Use a simple multiplication:

t2.id = -1 * t1.id'

Upvotes: 5

Related Questions