Select problem SQL

Users of the web site enter criteria to retrieve information in the MySQL database.
They can enter a value for the criteria or leave emty. When a criterion is empty, all the values are correct.
For example, they can find the records for:
1-city = Paris
-price = 50
In this case, I have to return the Portal: City = Paris and price = 50
2-city = Paris
-price = "" (no value)
In this case, I have to return the Portal: City = Paris, no matter the price.

For the first case, a select as:
"SELECT * from annonces_immo City WHERE = %s and %s = price.
works.
But it does not work for the second case because the value clause.
The research of system for records with city = Paris and price = ""; no records are returned.
Does anyone have an idea to solve this problem?

Thank you.

You must add the conditional code that will build the sql string based on the content of the criteria. If the criteria is empty, don't add where clause for the sql string.

Tags: Dreamweaver

Similar Questions

  • T - SQL-> conversion of PL/SQL: Insert... select problem

    Hello!

    If I have an insert in... Select T - SQL statement without a clause "from":

    Bq. insert into sometable (foo, bar)-select 5, case when @bar = 5, then 4 3 other purpose
    its translation is:

    Bq. INSERT INTO sometable------(foo, bar)-VALUES (CASE 5,------WHERE 5 = 5 THEN 4-3 OTHER------neck END);
    and I got: ORA-00917: "missing comma" for this. I don't know if this is a bug in the code of migration, or is there something so that I can use 'CASE' in an insert into... statement values somehow?

    Zoli

    You must remove the column name. I've just simplified your test case to check and it works:

    CREATE TABLE test(
      id NUMBER
    );
    
    INSERT
      INTO test(id)
      VALUES(CASE WHEN 5=5 THEN 4 ELSE 3 END)
    ;
    
    SELECT *
      FROM test
    ;
    

    C.

  • I have problem sql statement, can someone help me?

    How are you?

    SQL > select * from tst

    2 order by id, vacdate;

    ID VACDATE VACINTERV

    ---------- --------- ----------

    10-15 JANUARY 13 4

    10-25 JANUARY 13 6

    10-27 JANUARY 13 4

    20-15 JANUARY 13 4

    40 1 MAY 13 3

    40 13 OCTOBER 13 7

    50 13 OCTOBER 13 7

    50 17 OCTOBER 13 7

    60 24 MAY 13 5

    60 24 MAY 13 3

    This table contains the id == > employee id & vacdate == > is the start date of the holiday of employees & & vacinterv = > means the time interval of the holidays for example 7 7 days from 13 October 13 until 20 October 13

    the problem is there are used (IE id 10) take vacations that overlap [take 25 January 13 (range 6) until 21 January 13] but take by mistake January 27, 13 other vacation causing Holiday overlap

    How to select employees who will have a vacation that overlap?

    [email protected]

    LAG analytical use:

    with t as)

    Select tbl.*,

    case

    When trolling (vacdate + vacinterv, 1, vacdate) over (partition by order of identification by vacdate) > vacdate, 1

    end overlap_indicator

    from tbl

    )

    Select distinct id

    t

    where overlap_indicator = 1

    /

    ID
    ----------
    10
    50
    60

    SQL >

    SY.

  • Strange problem SQL

    I have a really strange problem and I hope someone here can explain to me why this is happening:

    I have run this query, it must return segment2 only if the first character is alpha and the 2nd character is the number.

    SELECT
    GCC. Segment2
    , SUBSTR (apps.gl_flexfields_pkg.get_description_sql (gcc.chart_of_accounts_id, 2, gcc.segment2) 1, 40) segment2_desc
    OF gl_code_combinations gcc
    WHERE (REGEXP_LIKE (substr (segment2, 1, 1), ' ^ [a-zA-Z] * $') AND)
    SUBSTR(Segment2, 2,1) NOT LIKE ' % [^ a-zA-Z] %');

    If it returns the correct results as well as the description segment:

    X 01234
    X 12345
    X 54321

    etc.

    Run the query, even with added active _flag where clause and expressions do not work:

    SELECT
    GCC. Segment2
    , SUBSTR (apps.gl_flexfields_pkg.get_description_sql (gcc.chart_of_accounts_id, 2, gcc.segment2) 1, 40) segment2_desc
    OF gl_code_combinations gcc
    WHERE (REGEXP_LIKE (substr (segment2, 1, 1), ' ^ [a-zA-Z] * $') AND)
    SUBSTR(Segment2, 2,1) NOT LIKE ' %[^a-zA-Z]%')
    AND gcc.enabled_flag = 'Y ';

    Returns a list with a value of segment with its description:

    DT101
    DT101

    etc.

    Why is this happening? I intend to use this query in a set of values. Just try it in Toad and SQL Developer right now.

    I doubt that addition of active flag has something to do with your problem, it does not change the results, but your original query will also return DT101, you have simply not can return all rows to view.

    SQL> l
      1  with t as (
      2     select 'X01234' col from dual union all
      3     select 'X12345' from dual union all
      4     select 'DT101' from dual union all
      5     select '1234A' from dual)
      6  select * from t
      7  where REGEXP_LIKE(substr(col, 1,1), '^[a-zA-Z]*$') AND
      8*       SUBSTR(col, 2,1) NOT LIKE '%[^a-zA-Z]%'
    SQL> /
    
    COL
    ------
    X01234
    X12345
    DT101
    

    The predicate regexp_like verifies that the first character of col is a letter. The is not as predicate checks that the second character does not contain the literal string "[^ a-zA-Z]". Because a single character will never contain a string of nine characters, it always evaluates to true.

    I think that you need something more like:

    SQL> l
      1  with t as (
      2     select 'X01234' col from dual union all
      3     select 'X12345' from dual union all
      4     select 'DT101' from dual union all
      5     select '1234A' from dual)
      6  select * from t
      7* where REGEXP_LIKE(col, '^[a-zA-z][0-9]*$')
    SQL> /
    
    COL
    ------
    X01234
    X12345
    

    Although something like this would be probably in a non ascii character set.

    SQL> with t as (
      2     select 'X01234' col from dual union all
      3     select 'X12345' from dual union all
      4     select 'DT101' from dual union all
      5     select '1234A' from dual)
      6  select * from t
      7  where REGEXP_LIKE(col, '^[[:alpha:]][[:digit:]]*$');
    
    COL
    ------
    X01234
    X12345
    

    John

  • Problem SQL querry (case statement...)

    Hi to everyone who reads this.

    I have a huge problem (at least for me) with a SQL I try to write in Oracle forms6 (yes I know... old app).

    OK, here it goes...

    We have a table like:
    create table temp (
      year     number 
      month    number,
      konto    number,
      DEBET    number, 
      KREDIT   number,
      date_tr  date,
      ind      number
    );
    The data in the table are:
     YEAR        MONTH    KONTO      DEBET     KREDIT DATE_TR  IND
    ---------- ---------- ----- ---------- ---------- -------- -
          2011          1 12101   4674,32           0 05.06.11
          2011          6 12101  -4674,32           0 05.06.11 R
          2011          6 12182   4674,32           0          R
    Now, to explain a little what I want to do...
    case when p_date > NVL(date_tr,'01012004') then
    date_tr is null;
    else
    ind is null
    end
    What I need is when p_date is entered by a user SQL should check if the date is less or greater than date_tr...
    in this case it should show only the record that has a null value in date_tr cullum.

    Or if it isn't... it should display records which is null in ind cullum.


    The main problem is that I do not know how to write the case statement in SQLs where clause... maybe someone can give me a hint
    or a partial code how do I solve this problem.

    Any ideas would be greatly apreciated.

    Thanks to you all!
    SQL> with temp as
      2  (select 2011 YEAR,1 MONTH, 12101 KONTO, 4674,32 DEBET, 0 KREDIT, to_date('05.06.11','DD.MM.YY') DATE_TR, NULL IND from dual union all
      3  select 2011, 6, 12101, -4674,32, 0, to_date('05.06.11','DD.MM.YY'), 'R' from dual union all
      4  select 2011, 6, 12182,  4674,32, 0, NULL, 'R' from dual
      5  )
      6  SELECT *
      7  FROM   temp
      8  WHERE  CASE
      9           WHEN To_date('&dt, 'DD.MM.YYYY') > (SELECT MAX(date_tr)
     10                                               FROM   temp) THEN To_char(date_tr)
     11           ELSE ind
     12         END IS NULL;
    Enter value for dt: 30.06.2011
    
          YEAR      MONTH      KONTO       4674      DEBET     KREDIT DATE_TR   I
    ---------- ---------- ---------- ---------- ---------- ---------- --------- -
          2011          6      12182       4674         32          0           R
    
    SQL> /
    Enter value for dt: 30.05.2011
    
          YEAR      MONTH      KONTO       4674      DEBET     KREDIT DATE_TR   I
    ---------- ---------- ---------- ---------- ---------- ---------- --------- -
          2011          1      12101       4674         32          0 05-JUN-11
    
    SQL>
    
  • Selecting a SQL Server 2005 with names of long columns (> 30 characters)

    Hello

    I was able to put in place a db Oracle 11.2.0.1 link to SQL Server 2005 using DG4ODBC.

    My problem is that some column names in Sql Server are more than 30 tanks and trying to select gives me the ORA-00972: identifier is a mistake too long.

    If I omit those select columns succeeds.
    I know that I can create a view in sql server and query it instead of the original table, but I was wondering if there is a way to overcome it with sql.

    My selection looks like this:
    select "good_column_name" from sometable@sqlserver_dblink -- this works
    select "good_column_name","very_long_column_name>30 chars" from sometable@sqlserver_dblink -- ORA-00972
    Thank you

    No there is no other way then using a view in SQl Server and select in the view rather than the table. The reason is that the Oracle database has a restriction that the column names must be 30 or fewer characters.

  • Select problem with a statement in the stored procedure oracle

    Hi guys,.

    I am new to oracle. I have a simple sql stored procedure that needs to be converted to oracle. The procedure is,

    CREATE PROCEDURE my_procedure
    Char (4) @my_var = null
    AS

    Select * from my_table where my_variable = @my_var

    I converted this SP as oracle and the convert SP is,

    create or replace
    My_procedure PROCEDURE
    (
    v_my_var in CHAR DEFAULT NULL
    )
    AS

    BEGIN

    SELECT * FROM my_table WHERE my_variable = v_my_var;

    END;

    But the SP above returns an error (Error (13.3): PLS-00428: an INTO clause in the following SELECT statement) when compiling.

    So I used the slider to get the results and send back them. Updated the SP is,

    create or replace
    My_procedure PROCEDURE
    (
    v_my_var in CHAR NULL by DEFAULT,
    cv_1 ON SYS_REFCURSOR
    )
    AS

    BEGIN

    OPEN cv_1 to SELECT * FROM my_table WHERE my_variable = v_my_var;

    END;

    Now, the SP is compiled successfully and return the result set correctly. My doubt is,
    What is the right way to solve the problem that I mentioned above? Is there another way to get the select query result without using a cursor?

    Please advice. Thank you for your help in advance.

    RAM

    Depends on where you are calling from SP.
    I assume you are using a windows client, as you referred to SQL Server.
    The .NET Oracle provider, allowing return of pl/sql types and as you return only all columns in a single line, you could change your procedure to something like this:

    create or replace procedure my_procedure(v_my_var in  char default null
                                            ,cv_1     OUT my_Table%rowtype) as
    
      rt my_table%rowtype;
    begin
    
      SELECT *
      into   rt
      FROM my_table
      WHERE my_var = v_my_var;
    
      cv_1 := rt;
    
    END my_Procedure;
    /
    
  • Distribution kit and problem SQL

    Hello

    I have a strange problem with the Toolbox Kit of Distribution and SQL.

    I use CVI 9.1 on win XP,

    I created a program that connects to a database extraction it's info to the lists, when you use the software in CVI everything OK, workers

    After creating a Distribution of this sweet install on another computer and update the database in the ODBC program works fine BUT I can't get anything from the database,

    the key, but noting happen without msg or error code.

    Any ideas?

    Hello-

    There are a few additional steps that must be taken when distributing the SQL Toolkit.  Please take a look at the help topic located at the following your help of LabWindows/CVI main location:

    Library reference > SQL Toolkit library > distributing a SQL Toolkit executable or a DLL

    Let me know if this does not fix things for you-

    NickB

    National Instruments

  • Problem SQL HELP during the installation of aviation the interactive dvd course!

    try to download interactive dvd Aviation course and be sktc kingschool SQL error does not exist... Check the State of SQL express instance and I install the classes I get a SsRestart occurred must close and send error report... Any help would be great!    Help!

    I suggest that you contact the manufacturer of the interactive DVD software to help get the program installed.

    They would be better able to help with your problem.

    Thank you

    Marilyn

  • HP Designjet 800ps paper selection problems

    I loaded the drivers etc for the HP DeisgnJet 800ps.

    It feels good, but I can't access the book 'Architecture' list set sizes in the "Properties".   I click on 'architecture', but the sizes of the paper do not appear in the drop-down list.  Can someone help me solve this problem.

    I have two other computers, and they recognize the architectural paper selections.   Thank you

    I'm linking you the Designjet forums below. Please just transfer your question their TI will be more likely to have answered.

    Designjet forum

  • Automatic selection problem Inspiron 6400 Audio input

    At the beginning, when pluging microphone or line-in for entry level jacket, the system would pop up, an input switch, asking me if it was microphone or line. He has stopped that for some time now. I have had no cause of problems, I just used the microphone, but now I want to record from a device external and it just will not work.

    I tried to select through recording Volume (Windows XP) but when I select LINE IN it just will not save anything. And if I select the Microphone, with the external audio gets saturated even with boost off (and the external device's display at the right level)

    I need a way to tell the computer I am pluging LINE IN if she allows the entrance to the lower level of GPA while selecting the RECORDING VOLUME online

    Help, please. Thank you.

    Hi best scorer.

    I suggest you to reinstall the audio driver for the resolution of the problems. Please enter your service tag # on the link below, select the operating system and download driver audio Audio section on the system and install it.

    http://Dell.to/ZaQuel

    Please let me know if it helps.

  • Newb problem SQL

    I'm a new development.  The most I've ever done is some files .bat to automate simple tasks.  This is a new path for me and has been a fun project to work on in my spare time.

    I wanted to take a crack with the Adobe AIR SDK to make an application for the PlayBook for us help in our Organization.  I followed thisguide on the use of local database features.  I have also read through this guide in two parts (part 1, part 2) on the functionality of SQLite.

    I have install the script to create a database, and the table if it does not exist.  I built form and, on the other hand, the DataGrid built.  The "Save" button calls the function of addSite.  I have information, press on save and get this error:

    TypeError: Error #1009: cannot access a property or method of a null object reference.
    hand / refreshNetworkSites [C:\Users\John\Adobe Flash Builder 4\Manager\src\Main.mxml:36])
    hand / addSite () [C:\Users\John\Adobe Flash Builder 4\Manager\src\Main.mxml:48]
    hand / __Save_click [C:\Users\John\Adobe Flash Builder 4\Manager\src\Main.mxml:61])

    Debug kicking back me and highlights the line required for this function:

    private function refreshNetworkSites (): void
    {
    var statementQLStatement = new SQLStatement();
    statement.sqlConnection = connection;
    Statement.Text = "SELECT * FROM SITES;
    Statement.Execute ();
    SiteGrid.dataProvider = statement.getResult () .data;
    }

    The database file is NetworkSites.db.  The data grid is required.

    I don't know what other code snipplets might be needed to help me solve this problem, but any idea is certainly appreciated!

    If you mean, by step, another class then yes it probably is. you will need to be accessible data required grid somehow in order to to use in other classes. or you can create a new instance of it in your new class so you don't have to share an object over the bowl of two classes. they will share the same data but operate independently of the other.

  • Odd selection problem

    I have Lightroom CC on a Win10 machine and just noticed a strange problem. First of all, I couldn't apply keywords to more than one image (using the method of selecting multiple, even when selecting multiple images with the spray can or copy/paste methods). Later, I was in the Loupe cross 'choose' images and selection in the back panel only was not "updated" what images I was actually display, which means all of the photos that I thought that I had marked as a pickaxe (by using the keyboard shortcut) were not actually marked as such because they have not been selected. I have a stuck key on my keyboard or something like that. It's really throwing a key into my workflow this evening. I need to get through 119 images for the work, which usually takes me about 30-40 minutes even with the changes, and so far I spent easily 40 minutes just having to go through and fix all the errors of selection. I only started to edit again, but I suspect that it will be very unpleasant since I usually picky and such c/p or sync/changes of settings across multiple images, especially for the color corrections. Should I uninstall and reinstall? Of course what is going on a very long day = P also, my version before moving on to the CC was 5 I think, just in case they have changed the way of doing the basic things and I never got the memo lol.

    Edited to add: this is today, freezes frequently while I'm editing. I'll probably try a new installation and see how it goes.

    Yes, try updating your driver by going directly on the manufacturer's site to get the latest.  If this does not help, you can disable the use of the GPU manually by following the instructions here: Adobe Lightroom GPU troubleshooting and FAQ

  • selection problems

    Hello

    I have a problem with hearing CS6. I can't select more than one part of a railway with the Brush tool in spectral frequency display. Normally it should work with pressing SHIFT, but it doesn't. Also, it is not possible to remove some ofe EIB selected part by pressing ALT do you know what I mean?

    I'm grateful for any help!

    Best,

    Peter

    These options do not exist in CS 6 hearing I'm afraid. They only did return in Audition in the first version of the CC.

  • Eliminate the duplicate based on the condtion in Select of SQL query.

    Hi all

    I write the SQL query where I have to select values based on the condition in the column.

    Lets say I have 3 columns position, description, used, there are different values in the position but for some positions of the column description of the lines is the same and if column Description is the same and employee is null then that there should be only one row returned and if the description is the same but the employee column is not null then it should be several lines.

    I can't use Group by that we have around 35 columns in the select query.

    Please suggest any Solution.

    Hi Michael,

    I adds a column to the t2 to get the good understanding of my needs.

    Level
    Employee From Date to_date
    1 Test2 21.03.2014 21.04.2014
    2 Test4 21.02.2014 20.03.2014
    2 Test1 21.03.2014 21.04.2014
    2 Test3 21.04.2014
    3 MgrTest 21.03.2014

    Now, the result should look like this.

    Level
    Employee From Date TO Date
    1 Test2 21.03.2014 21.04.2014
    2 Test3 21.04.2014
    2 Test1 21.03.2014 21.04.2014
    3 Mgrtes 21.03.2014
    4

    There was an addition more as if this day is not null for the given level, then the query must return a single line of balnk more with the same position, I am reached using any Union and works very well I'm stuck with the point above.

Maybe you are looking for

  • How can I disable print preview

    I installed Firefox 38. I've been avoid for a year because of the stupid that UI changes that really pss me off. I don't like Chrome and IE even more, so I'm finding how to get things to work as they did before. Once, when I clicked on the print butt

  • Qosmio X 870 PSPLXA 00T00E - details of the motherboard

    I have WIndows 7 Home Premium 64 bit on this computer. I have trouble finding information about the motherboard for islet need to know if she will be able to handle the SATA III or has only been designed to SATAII. Also, what is the maximum size hard

  • ANALYSIS OF the CHAIN fails with empty quoted strings

    I'm scanning a long text with the STRING SCAN line. "[My problem in the first place of this part: " [^] "]" The string I'm scanning a quotes in it - I want to extract the string in quotes as a single item. I can't use %s because the string can have s

  • Analog output of signal generation custom

    Hello I have a VI that generates a signal from the values in an excel worksheet. I'm trying this waveform through an acquisition of output data. I use a box NI USB-6211. I copied the exit code for the acquisition of data from other VI that generates

  • How can I block specific people from my computer and emails?

    How can I block emails specofic?