Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 502
  • Last Modified:

Crystal Report

I have table that 5 columns
ID   Name    Account1    Account2 Account3 Account4
19   John       212                444            325           0
22   Chris      333                212            213         234
15   Steve     212                458             235         213
12    Jim        324                876            123          212.

I would like to retrieve all the data that have "212" Account#. It could be in any column.

What SQL Statement I can use to get this data?
0
snhandle
Asked:
snhandle
2 Solutions
 
PortletPaulCommented:
If an account number is a string then use '212' if it is an integer just use 212
SELECT
      ID
    , Name
    , Account1
    , Account2
    , Account3
    , Account4
FROM ThatTable
WHERE (  Account1 = '212'
      OR Account2 = '212'
      OR Account3 = '212'
      OR Account4 = '212'
      )

Open in new window

0
 
mlmccCommented:
The above comment will work if you are creating the view in the database or using a COMMAND as the data source.

If you are doing this in Crystal you only need to have the WHERE part in the SELECT EXPERT.

{YourTable.Account1} = "212"
OR
{YourTable.Account2} = "212"
OR
{YourTable.Account3} = "212"
OR
{YourTable.Account4} = "212"


If the field is numeric remove the " " around the 212

mlmcc
0
 
James0628Commented:
Just for the heck of it, this is a slightly different way to do the same thing:

"212" in [ {table.Account1}, {table.Account2}, {table.Account3}, {table.Account4} ]


 It's not really any better.  Just different.  Maybe a little "simpler".

 James
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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