This problem is eating up my brain for the past few hours.
I have 2 tables:
**domain_pricing**
action enum()
map varchar(10)
cost_price varchar(10)
sale_price varchar(10)
**domain_mapping**
map varchar(10)
tld varchar(10)
map is common for both tables.
sample data:
**domain_pricing**
addnewdomain,dotbiz,12,13
renewdomain,dotbiz,12,13
transferdomain,dotbiz,12,13
**domain_mapping**
dotbiz,biz
dotbiz,fizz
dotbiz,jizz
what i need after join:
biz,addnewdomain,12,13
biz,renewdomain,12,13
biz,transferdomain,12,13
fizz,addnewdomain,12,13
fizz,renewdomain,12,13
fizz,transferdomain,12,13
jizz,addnewdomain,12,13
jizz,renewdomain,12,13
jizz,transferdomain,12,13
my query:
select m.tld,p.action,p.sales_price,p.cost_price from domain_pricing as p, domain_mapping as m where p.map=m.map
result:
biz,addnewdomain,12,13
biz,renewdomain,12,13
biz,transferdomain,12,13
dats all, tried doing left join but that gave all values for biz then fizz,null,null and finally jizz,null,null
Can’t figure out where i’m going wrong
I think solved your problem. And the best part is that there is nothing wrong with your query. 😉 You only made a typo in you query. That happens to everybody.
select m.tld,p.action,p.sale*s*_price,p.cost_price from domain_pricing as p, domain_mapping as m where p.map=m.map
It should be:
The difference is that you query looks for the non existing column sale*s*. The column you want is sale.
See it in action: http://www.sqlfiddle.com/#!2/f6b83/7
B.T.W. I’m not sure why you would need enum for action? I would suggest to use an integer column for the primary key instead.