Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: SQL problems Post Reply Post New Topic
Author Message
andrew
Newbie
Newbie
Avatar

Joined: 11 Nov 2008
Location: United Kingdom
Online Status: Offline
Posts: 35
Quote andrew Replybullet Topic: SQL problems
    Posted: 30 Jun 2009 at 8:24am
Hi All,

I'm at the end of my tether here where i've been trying to get something (that would take about 10 seconds to do in any programming language) to work in Crystal. And im at the stage where im ready to chuck the computer out of the window.

All I want to do is something like:

SELECT "Name" FROM "Clients" WHERE "Clients.ID" = "Quotes.Contact_ID"

and it seems like something *that* simple is too complex for Crystal to handle, which has to be false.

Anyone have any ideas?

Thanks
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jun 2009 at 8:34am
Hi Andrew. Sorry your Crystal frustration levels have reached window breaking levels. Just make sure your car is not parked under that window.
 
Not sure where you are at in the overall process so I will start at the beginning of the design although I have a feeling you are in the middle of a report and are trying to create a formula field...
Add the CLients Table to the report
Add the Quotes table to the report
Inner Join Clients.ID to Quotes.Contact.ID
Drop the Clients.Name field onto your report.
 
If my concern about the formula field was right please post a little more explanation of the report and what you are trying to do with the code.
 


Edited by DBlank - 30 Jun 2009 at 8:35am
IP IP Logged
andrew
Newbie
Newbie
Avatar

Joined: 11 Nov 2008
Location: United Kingdom
Online Status: Offline
Posts: 35
Quote andrew Replybullet Posted: 01 Jul 2009 at 12:54am
Hi DBlank,

Thanks for replying.

I dont think i've explained myself clearly enough due to the heat of the moment.etc.

To be clear:
The linking is done and correct.etc however I need to perform two seperate lookups to the same database table in order to retrieve the information required to get the right data into the report.

Essentially, the client table in this circumstance holds both the company information as a row as well as a row for the primary contact within the table. (I didn't design the database, its from a CRM package I should add).

So the db will have a schema as follows:

ID    Name             CID
1     Company X     3
2     John Doe        3

So in the Report it will have something like:

Contact: John Doe
Company: Company X
Address: ....

Now as the report gets generated through the CRM - I thought the best way to deal with the issue was to use a SQL query to get the correct details (which i've done countless times  in php / c / asp.net and so on for various other projects).

So literally, it just needs to be something as simple as the sudo code I wrote in my first post (SELECT "Name" FROM "Clients" WHERE "Clients.ID" = "Quotes.Contact_ID"), But Crystal just wont play ball, and whilst recognises commands like 'SELECT' doesnt appear to understand anything else - making me rip my hair out.

Any ideas?
IP IP Logged
andrew
Newbie
Newbie
Avatar

Joined: 11 Nov 2008
Location: United Kingdom
Online Status: Offline
Posts: 35
Quote andrew Replybullet Posted: 01 Jul 2009 at 6:29am
Fixed!

Incase anyone else searches the forum for a similar thing, I loaded in the same table twice and called one 'clients' and one 'contact',

I then linked the contact ID to the main table that I was searching against and it all came good (if that makes any sense), so I could run two queries to get two lots of data from the original table.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Jul 2009 at 7:06am
Glad you go that fixed. You should have been able to write your SQL query in as a COMMAND in the DB Expert though.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.035 seconds.