0

Im having some issues getting the result I want from two tables

table #1: history customer_id | Action ------------------------ 217 | buy ------------------------ 218 | sell ------------------------ 219 | hold ------------------------ table #2: Customers customer_id | name ---------------------------- 217 | Alan ---------------------------- 218 | Jan ---------------------------- 219 | Rick 

I have a really long query now, but essentially I want to add to match the name with the amount. I tried this but it didn't work:

(SELECT action AS action FROM "history` LEFT JOIN ON " customer(customer_id=customer_id)`) 

I'm not really familiar with doing queries so any help would be appreciated

0

3 Answers 3

2

It should be this:

SELECT h.Action AS action FROM history h LEFT JOIN Customers c ON h.customer_id = c.customer_id 

You either need to specify the tables or create an alias with which to associate columns/data.

Sign up to request clarification or add additional context in comments.

2 Comments

Is this the low hanging fruit?
Just checking ;-)
0

Is a simple join

select action from history left join Customers on Customers.Customer_id = history.customer_id 

and you can confirm using

select history.customer_id, Customers.Customer_id history.action , Customers.name from history left join Customers on Customers.Customer_id = history.customer_id 

Comments

0

You can JOIN tables like this:

SELECT history.action AS Action ,Customers.name AS Name FROM `history` LEFT JOIN `Customers` ON history.customer_id = Customers.customer_id; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.