Joined: 30 May 2012
Online Status: Offline
Posts: 2
Topic: Join tables on strings Posted: 30 May 2012 at 3:37pm
I have a customer database table contains
customer name (ex: John Doe), another column for customer ID number, other columns.
I have a beverage database table also contains
customer name, plus the type of beverage they purchased (wine, beer, cocktail) in the same text field (ex: John Doe beer).
I must use the beverage
table to pull only the beer drinkers (keyword is beer, if you've been drinking), and then list them by their name and ID
number from the customer table.
So there must be a join
between the tables. A join on strings. I've tried for weeks with no luck. Is it not possible to join on text strings? Such as a condition "Select Beverage.Name where if instr 'beer' and "Customer.Name" then Customer.Name and Customer.ID" etc? The goal is to get the ID and other info from the customer table only for the beer-drinking subset of customers in the beverage table.
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 31 May 2012 at 3:37am
Do you have any other fields in the beverage table that you can use tolink through a thord or forth table?
in a crystal command (or view or stored proc) you could try to link using a LIKE clause but if you have nay customer with the same name you will get back multiple hits
Joined: 30 May 2012
Online Status: Offline
Posts: 2
Posted: 31 May 2012 at 5:45am
No, I have no other fields in the Beverage table. Getting dup names is not an issue. I'm using CR 2008. I have to match text strings. I can already get the beer subset. Now I just need to connect the Beverage table to the Customer table. If you're matching a text string do you put the text field in quotes even though it's already in curly braces? And it's conditional, right, so I need an If-Then statement? Do you say If instr {Beverage.Name} "{Customer.Name}" then {Customer.ID}? Do you say If {Beverage.Name} LIKE "{Customer.Name}" then {Customer.ID} ?
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 31 May 2012 at 8:17am
You would need to do this at the join which would require you to use a command object. I have never used LIKE in a join before as I am sure it is not efficient but it is the only way I can think of your situation working.
You command will look something like this
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