Visualizzazione dei risultati da 1 a 4 su 4

Discussione: il contrario di LIKE..

  1. #1

    il contrario di LIKE..

    Ciao a tutti,

    devo estrapolare da una tabella 'A', tutti i record in cui il campo 'b' NON contiene un valore dato.
    In genere il campo 'b' ha valore nullo, salvo alcuni casi in cui potrà avere una o più stringhe del tipo '[XX]', dove 'XX' è un valore variabile, separate da virgola ([XX],[YY]..) A questo punto devo poter selezionare tutti i record che hanno b nullo o b non contenente [XX].. pensavo la clausola b NOT LIKE '%[XX]%' potesse andare.. evidentemente non è così perchè tende a restituirmi recordset vuoti.

    Idee su come procedere?
    MR. PINK
    "Like a Virgin" is all about a girl who digs a guy with a big dick.
    The whole song is a metaphor for big dicks.

  2. #2
    Utente di HTML.it L'avatar di neroux
    Registrato dal
    Aug 2009
    Messaggi
    1,973
    Hai provate

    codice:
    b NOT LIKE '%[XX]%'

    www.sitemeer.com » Quando un sito pare irraggiungibile

    Se ti piace ci puoi trovare anche su Facebook

  3. #3
    Si, infatti ho appena modificato il post.. NOT LIKE o NOT(b LIKE) ugualmente non restituiscono record.. sebbene al momento il campo b sia vuoto per tutti
    MR. PINK
    "Like a Virgin" is all about a girl who digs a guy with a big dick.
    The whole song is a metaphor for big dicks.

  4. #4
    Dalla documentazione di MySQL (che la prossima volta leggerò prima )

    This is the same as NOT (expr LIKE pat [ESCAPE 'escape_char']).

    Note
    Aggregate queries involving NOT LIKE comparisons with columns containing NULL may yield unexpected results. For example, consider the following table and data:


    CREATE TABLE foo (bar VARCHAR(10));

    INSERT INTO foo VALUES (NULL), (NULL);

    The query SELECT COUNT(*) FROM foo WHERE bar LIKE '%baz%'; returns 0. You might assume that SELECT COUNT(*) FROM foo WHERE bar NOT LIKE '%baz%'; would return 2. However, this is not the case: The second query returns 0. This is because NULL NOT LIKE expr always returns NULL, regardless of the value of expr. The same is true for aggregate queries involving NULL and comparisons using NOT RLIKE or NOT REGEXP. In such cases, you must test explicitly for NOT NULL using OR (and not AND), as shown here:

    SELECT COUNT(*) FROM foo WHERE bar NOT LIKE '%baz%' OR bar IS NULL;
    MR. PINK
    "Like a Virgin" is all about a girl who digs a guy with a big dick.
    The whole song is a metaphor for big dicks.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.