bagofmilk
bagofmilk

Reputation: 1550

phpmyadmin SQL query multiple tables

I have two tables.
(1) compressors
(2) crankcase_heaters

I'm trying to create a SQL query to do:

Essentially this query will reproduce my compressors table but will have another 'column' called "CRANKHTR".

I'm completely lost on where to even start with this. I tried using the phpmyadmin SQL Query builder but i have no idea where to begin.

Upvotes: 0

Views: 2553

Answers (1)

dethtron5000
dethtron5000

Reputation: 10841

Without seeing the exact data structure, it sounds like you need a simple INNER JOIN:

SELECT 
    `cp`.`VOLTAGE`, 
    `cp`.`WATT`,
    `ch`.`PARTNO` as CRANKHTR
FROM
    `compressor` cp
    INNER JOIN `crankcase_heaters` ch ON ch.VOLTAGE = cp.VOLTAGE AND ch.WATT = cp.WATT

Upvotes: 1

Related Questions