473,473 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need to extract only some values from the table

12 New Member
Hello Everyone,

I am looking for some help again....

So my table has CompanyID, companyname, companytype, address, Phone, and Fax etc...

I want to extract records that only have phone no. and nothing else. My query is giving me all companies that have phone so it's including fax, address etc. which i don't to see. i want the query to return the companyids that have phone numbers only.

Any help on this much appreciated,

Thanks,
S
Apr 25 '07 #1
4 1111
michaelb
534 Recognized Expert Contributor
Try this:
Expand|Select|Wrap|Line Numbers
  1. SELECT * from myTable WHERE Phone is not null AND
  2. (CompanyID is null and companyname is null 
  3. and companytype is null and address is null and Fax is null);
  4.  
Depending on your situation (the database you use and how values are collected and inserted) you may need to replace
"field is null" with field = '' // two single quotes
and
"field is not null" with field != ''
Apr 25 '07 #2
srathi
12 New Member
thanks for the quick response. my table has over 300 fields so i would have to do the null or '' for each. is there a faster way to do this?
Apr 25 '07 #3
michaelb
534 Recognized Expert Contributor
Nothing I can think of.
Of course you can create a view and list all these columns only once, then just do a select from view Keep in mind that you are going to do a full table scan, so if your table is large it may take a while for this query to complete.

You may need to address this issue elsewhere, it does not seem reasonable that application allowed to insert these records on the first place.
Apr 26 '07 #4
srathi
12 New Member
Nothing I can think of.
Of course you can create a view and list all these columns only once, then just do a select from view Keep in mind that you are going to do a full table scan, so if your table is large it may take a while for this query to complete.

You may need to address this issue elsewhere, it does not seem reasonable that application allowed to insert these records on the first place.
yeah. thanks for the help!
Apr 26 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
5
by: Chad Richardson | last post by:
Is there a way in SQL Server 2000 to extract data from a table, such that the result is a text file in the format of "Insert Into..." statements, i.e. if the table has 5 rows, the result would be 5...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
14
by: Bombus | last post by:
Hello. I have two different types of MS Access databases (A.mdb). One is on a server, and several databases at clients (B.mdb). Now I want to develop some code that can extract data from the...
8
by: Fabian Braennstroem | last post by:
Hi, I would like to remove certain lines from a log files. I had some sed/awk scripts for this, but now, I want to use python with its re module for this task. Actually, I have two different...
9
by: Paulers | last post by:
Hello, I have a log file that contains many multi-line messages. What is the best approach to take for extracting data out of each message and populating object properties to be stored in an...
0
by: napolpie | last post by:
DISCUSSION IN USER nappie writes: Hello, I'm Peter and I'm new in python codying and I'm using parsying to extract data from one meteo Arpege file. This file is long file and it's composed by...
47
by: ndedhia1 | last post by:
I have data in a database that looks like this: INSERT INTO ALARMNOTIFICATIONDETAIL VALUES ('1865', '2295', '15401', '1', 'Prodprdcons11InstrumentationMonitor', 'ALL'); INSERT INTO...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.