PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] SELECT All records from a table but the empty ones with an SQLite Database.-VBForums
Results 1 to 8 of 8

Thread: [RESOLVED] SELECT All records from a table but the empty ones with an SQLite Database.

  1. #1

    Thread Starter
    Addicted Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    185

    Resolved [RESOLVED] SELECT All records from a table but the empty ones with an SQLite Database.

    Hello!

    Im using an SQLite database and I have a table named Clients with a column named: Email. the rows in this column usually get values like a regular Email addresses but also sometimes they get values like: "@" or just nothing "".
    The column Email in the database is set to: TEXT type.

    I've tried the following queries to select only the rows that contain an Email address. The ones that contain: "@" or just nothing ""... don't select these.

    This query works but ONLY excludes the ones with '@' the ones with "" are still there.
    vb.net Code:
    1. command = "SELECT Email FROM Clients WHERE Email <> '@' OR Email <> ' "" ' "

    This query sends me an error
    vb.net Code:
    1. command = "SELECT Email FROM Clients WHERE Email <> '@' OR Email <> IS NULL "

    I'll appreciate any help!

  2. #2
    Fanatic Member
    Join Date
    Nov 2017
    Posts
    852

    Re: SELECT All records from a table but the empty ones with an SQLite Database.

    Code:
    command = "SELECT Email FROM Clients WHERE Email <> '@' OR Email <> ' "" ' "
    The pieces in between the ' characters are treated literally. So the part after the OR is saying:

    Select if Email is not equal to a space character followed by a double quote followed by another double quote followed by a space character. That clearly isn't what you want.

    Try this:

    Code:
    command = "SELECT Email FROM Clients WHERE Email <> '@' OR Email <> '' "
    Note that the red characters are two single quotes with no space in between them and not a double quote.

  3. #3

    Thread Starter
    Addicted Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    185

    Re: SELECT All records from a table but the empty ones with an SQLite Database.

    Hi OptionBase1 !!!

    Thanks for the feedback, I've change my query as suggested and still don't work.

    This works as I mentioned earlier:
    vb.net Code:
    1. command = "SELECT Email FROM Clients WHERE Email <> '@' "

    But as soon as I add this:
    vb.net Code:
    1. command = "SELECT Email FROM Clients WHERE Email <> '@' OR Email <> '' "
    It selects all the rows on Email's column.

  4. #4
    Fanatic Member
    Join Date
    Nov 2017
    Posts
    852

    Re: SELECT All records from a table but the empty ones with an SQLite Database.

    Yeah, try changing the OR to AND. You want to select everything that isn't blank AND isn't just an @ sign.

  5. #5
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,258

    Re: SELECT All records from a table but the empty ones with an SQLite Database.

    The logic is wrong.

    Code:
    command = "SELECT Email FROM Clients WHERE Email <> '@' AND Email <> '' "
    Think about it.

  6. #6

    Thread Starter
    Addicted Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    185

    Re: SELECT All records from a table but the empty ones with an SQLite Database.

    Hi OptionBase1 !!!

    Thanks for the feedback, I've change my query as suggested and still don't work.

    This works as I mentioned earlier:
    vb.net Code:
    1. command = "SELECT Email FROM Clients WHERE Email <> '@' "

    But as soon as I add this:
    vb.net Code:
    1. command = "SELECT Email FROM Clients WHERE Email <> '@' OR Email <> '' "
    It selects all the rows on Email's column.

  7. #7

    Thread Starter
    Addicted Member Spybot's Avatar
    Join Date
    Jan 2019
    Posts
    185

    Re: SELECT All records from a table but the empty ones with an SQLite Database.

    OK. it works now!
    Changing OR to AND
    Thank very much!

    But, why wes4dbt thinks the logic is wrong?

  8. #8
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,258

    Re: SELECT All records from a table but the empty ones with an SQLite Database.

    Quote Originally Posted by Spybot View Post
    OK. it works now!
    Changing OR to AND
    Thank very much!

    But, why wes4dbt thinks the logic is wrong?
    Because your logic was wrong. "OR" and "AND" are logic operators. You were using the wrong one. Do you understand why you needed to use the "AND" operator? Like I said "Think about it".

    Code:
    Email <> '@' OR Email <> ''
    If Email = "@" then it can't equal ' ' so that evaluates to TRUE
    If Email = '' then it can't equal "@" so that evaluates to TRUE

    So every record evaluates to TRUE.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width