• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

Re write the below sql's Sql server 2008

Can some one please help me in re writing the below sql

select *
from grp a,inv b,fds c ,suix d, link e ,aove f
where e.id*=d.inv_id
and a.inv_id=b.inv_id
and b.fd_id=c.fd_id
and a.inv_id=d.inve_id
and a.gp_id=e.gp_id
and e.gp_id=f.gp_id
and f.gp_id=a.gp_id

There is a non -anscii join in the first where condition .Can some one help me to re write the sql so that it works in sql 2008

Thanks
0
vijay11
Asked:
vijay11
  • 4
  • 4
1 Solution
 
Jared_SCommented:
I'm not sure what

"e.id*=d.inv_id " 

is trying to do.

Do you get your desired results if you change it to

"e.id = d.inv_id"?
0
 
vijay11Author Commented:
e.id*=d.inv_id  means left outer join similar as

from link e
left outer join suix d on e.id=d.inv_id
0
 
Jared_SCommented:
Try this:

select * from 

link e left outer join 

suix d on e.id = d.inv_id inner join   
 
inv b on  b.fd_id=c.fd_id inner join

grp a on (a.gp_id=e.gp_id and a.inv_id=d.inve_id and a.inv_id=b.inv_id) inner join

aove f on (f.gp_id=a.gp_id and f.gp_id = e.gp_id) inner join 

fds c on b.fd_id=c.fd_id

Open in new window

0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
vijay11Author Commented:
I am getting The multi-part identifier "c.fd_id" could not be bound.
0
 
Jared_SCommented:
Ok - round 2:

select * from 

link e left outer join 

suix d on e.id = d.inv_id inner join   
 
grp a on (a.gp_id=e.gp_id and a.inv_id=d.inve_id) inner join

inv b on  a.inv_id=b.inv_id inner join

aove f on (f.gp_id=a.gp_id and f.gp_id = e.gp_id) inner join 

fds c on b.fd_id=c.fd_id

Open in new window

0
 
vijay11Author Commented:
I dont get any  out put.

But when I remove the 2nd condition in the below line I get some data

grp a on (a.gp_id=e.gp_id and a.inv_id=d.inve_id)
0
 
Jared_SCommented:
Are "d.inve_id" or "d.inv_id" different fields, or is that a typo in the original query?

Changing

grp a on (a.gp_id=e.gp_id and a.inv_id=d.inve_id)

to

grp a on (a.gp_id=e.gp_id and a.inv_id=d.inv_id)

might fix it if it's a typo...
0
 
vijay11Author Commented:
yes it was the typo.But while running the query I fixed  it and deployed it.But I get not results and when I remove the condition as stated above I get the results as the original query.

Thanks
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now