Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Search for Non-Blank

Quote Reply
Search for Non-Blank
Is there a way to search for a field that contains something (on the admin screen) without specifying what it contains? In other words, can I search for a non-blank field that has anything in it?

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Search for Non-Blank In reply to
not from the admin, per se.

you can do that from an SQL statement, something like:

SELECT * From TABLE where Colname != ''


Now, i had some _REAL_ problems searching for "NULL" fields. When I did, I only got a few fields, rather than the 200+ I knew were there.

I couldn't find anything "different" about those fields. Nothing I could come up with would show the differences between a reall "NULL" and an "EMPTY"

Using MySQLMan, I was able to see that the fields I was trying to list as = '' were flagged as "NULL" in green. If they showed the green "NULL" they didn't show up on an SQL query "FIELD_NAME=''". If they were just blank, they did show up as " ='' ".

Ok, after an hour or so of trying different things (including isamchk, restarting MySQL, etc), I finally changed the column definition to disallow "NULL" fields. Once I did that, all the fields that were "NULL" or "EMPTY" showed up on the " ='' " comparason.

So... the moral? There are bugs in MySQL (I used 3 different programs each with the same results), and I figured this was as good a place as any to write about it <G>

If you are not getting the correct search on NULL fields, you might try changing the column definition from "NULL" to "NOT NULL" or back. This should not change any data, but it should "fix" up any problems in the empty/null fields.

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Search for Non-Blank In reply to
Hello Bobsie!

I have searched in this way many times to delete empty fields. I did not use any SQL commands. I used phpMyAdmin and click on the column that I wanted the order listed. It always gave the empty fields first which I wanted to delete.

This also means that that SQL query gives the results what you are looking for. You may want to have a look in there or perhaphs already have installed and could look in the location to find out what it does.

Quote Reply
Re: Search for Non-Blank In reply to
What is phpMyAdmin, something that comes with PHP3? Can the same thing be done with Perl (if you know)?

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Search for Non-Blank In reply to
MySQLMan is based on PHPAdmin. It's an add on you can get to from the list at the PHP3 site.

It allows management of the MySQL server via the web.

Also, WebAdmin has a new module that is under development, and for most server management it's a great program.

Essentially these are tools that wrap the interactive portion of the process in graphical web calls, obviating the need for telnet access. WebAdmin runs as a root daemon/server, and handles requests via a different port. MySQLMan and PHPAdmin only manage the MySQL server, and do so through standard HTTP access of your main server.

I find perl much easier to modify and to work with than PHP (I never liked mixing code in my output, which is why I like templates, rather than hard-coded html), and it keeps my mind working in one ring rather than two.

I don't really like Javascript because it asks the browser to do a lot of work that should be done by the program or server, and I guess I feel the same about PHP. It asks the server to do a lot of stuff that should be done by other scripts.

I don't like embedding code in my pages, and having that code and the pages in the public tree.

I don't have a problem with using PHP the way you'd use an SSI or simple Javascript code to "fillin the blank" with updated information such as time, a current hit status, or the like.

I can see maybe making the site CGI generated with perl, and the output pages be .php3 so I can embed some function calls into them.

But, once you go that far, you start to wonder if using the features of mod_perl you couldn't get better performance by just cgi-generating the whole site, rather than asking the server to parse the file and just fill in the blanks.

Time will tell which will win out. But neither is "better" for all instances.

My biggest problem with PHP is the code is in the template files, which is in the httpd tree, which is a potential security problem.

Also, I find I much prefer passing the variables/values as a hash to a subroutine in a secured directory, and having a parser fill in the blanks and just pass a filled out page back to the user.

This has been the new religious war, and it will probably get worse :)



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Search for Non-Blank In reply to
In Reply To:
Also, WebAdmin has a new module that is under development, and for most server management it's a great program.
Where can I find out more information about WebAdmin. I tried a search on the web and ended up with a large list of some real garbage links. Is it also on the PHP3 site?

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Search for Non-Blank In reply to
Hi!

Webmin: http://www.webmin.com/webmin/
PhpMyAdmin: http://www.htmlwizard.net/phpMyAdmin/
MysqlMan: http://www.gossamer-threads.com/scripts/mysqlman/

To search for fields that are not null:

SELECT * FROM table WHERE field IS NOT NULL

or to find ones that are NULL:

SELECT * FROM table WHERE field IS NULL

NULL is different then an empty string "" though.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Search for Non-Blank In reply to
Alex,

I tried this (see the bug experience a day or two ago).

Nothing would find the records -- I had to change the column descriptor.

I tried '', "", and NULL

This is not a Links problem, it was a 'quirk' with MySQL, since I couldn't do the searches in MySQLMan, PHPAdmin, or interactively.

I struggled for about an hour before I tried the flip the field definitions from 'NULL' to 'NOT NULL' (or vice versa). That seemed to reset everything in the table column, and they started showing up on the searches.


I wonder if there are (is the possibility of) three different "values" for a column field -- 'NULL', {NULL}, and {EMPTY}, where

'NULL' == 'NULL'
{NULL} == is whatever mysql adds to a field that is created
{EMPTY} == is a field that answers to '' or ""

MySQLMan was the most helpful, in that it showed the mis-behaving columns as a green 'NULL', and the columns that were answering the search as a blank/empty column.

This was an odd problem, that I mentioned in this thread just because it was odd Bobsie asked about searching for 'null' or 'blank' on the same day I was having this frustrating experience.



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Search for Non-Blank In reply to
Thanks for the URLs, Alex.

As to the searching, I was hoping there was a way to search for null (empty) variables from the LinksSQL admin screen in Perl and not SQL. Is there a way?

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: Search for Non-Blank In reply to
Hmm, there are:

'NULL' which is a string with the word NULL in it. To match this, you would do FIELD = 'NULL'

'' which is an empty string. To match this, you would do FIELD = ''.

NULL which is a NULL value. Note NULL != NULL, by definition NULL is unknown, and you can't apply equal, greater then, less then tests to it etc. To match a NULL field you need to do FIELD IS NULL. There shouldn't be an equal operator at all.

Not sure if that's what you tried or not. =)

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Search for Non-Blank In reply to
No, unfortunately there isn't. =(

Cheers,

Alex

--
Gossamer Threads Inc.