Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 01-23-2004, 03:02 PM   #1 (permalink)
Odoggy5
Registered User
 
Odoggy5's Avatar
 
Join Date: Aug 2003
Location: SF
Posts: 45
Odoggy5 is on a distinguished road
Send a message via AIM to Odoggy5
Access question...

should be pretty easy.

I just want to exclude a string of text from the results of a query, how can I do it?
Odoggy5 is offline   Reply With Quote
Old 01-25-2004, 12:15 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,711
redhead is on a distinguished road
Exclude a string ??
Something like:
Code:
$text = "";
$res = mysql_query("SELECT * FROM some_table WHERE (id = \"$SOME_ID\")", $DB_LINK);
while($row = mysql_fetch_array($res))
  $text .= str_replace("some text", "", $row);
mysql_free_result($res);
echo $text;
Or are you thinking more in the terms of only selecting items, where the text is not pressent ?
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 01-25-2004, 12:33 PM   #3 (permalink)
Odoggy5
Registered User
 
Odoggy5's Avatar
 
Join Date: Aug 2003
Location: SF
Posts: 45
Odoggy5 is on a distinguished road
Send a message via AIM to Odoggy5
yaeh
I want to select items where the text is not present.
Odoggy5 is offline   Reply With Quote
Old 01-25-2004, 02:57 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
select * from table where field IS NULL

or

select * from table where field=''
__________________
Mike
sde is offline   Reply With Quote
Old 01-25-2004, 09:35 PM   #5 (permalink)
Epsilon
Regular Contributor
 
Epsilon's Avatar
 
Join Date: Mar 2003
Location: Las Vegas, NV
Posts: 127
Epsilon is on a distinguished road
That brings up a question. Can you use the not operator in a MySQL statement, like:

select * from table where field!='something'
__________________
--Epsilon--
Epsilon is offline   Reply With Quote
Old 01-26-2004, 04:38 AM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,711
redhead is on a distinguished road
SELECT * FROM table WHERE something = something AND NOT some_other;
If I remember correct, it's been a while since I used the combined select.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 01-26-2004, 05:40 PM   #7 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
To further expand on sde's statement, you can combine the two easily to match any column without value or with an empty string, e.g.
Code:
SELECT * FROM sometable WHERE field IS NULL OR field = '';
Please note you can't use 'WHERE field = NULL' because any operation on NULL like that always returns NULL.

And yes you can use either the <> or != operators to signify the NOT.
bdl is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues with Access creed Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 7 08-23-2004 09:55 AM
MySQL vs MS Access Epsilon PHP 5 05-24-2004 02:28 PM
Access denied for user: '@192.168.0.71' (Using password: NO) infinite_root PHP 11 04-28-2004 05:30 PM
can't access bios sde Windows 4 08-10-2003 08:41 PM


All times are GMT -8. The time now is 10:53 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting