How less INT from another table

Hello

How could I go to try at least an intiger of two tables?

for example:

1 event has an availability of 100 seats.

1 user can complete 1 transaction (1 sheet) but select several places to book through this 1 transaction.

The event would then 98 seats available.

Untitled-1.png

It would be better to display through php, or it is set to a field in the event table (for example, current_availability)?

PS do not know if this makes sense.

So seats_amount of booking could be 1, 2, or more, depending on the number of reserved seats. With SQL, you can get the sum of the seats_amount like this: SELECT SUM (seats_amount) FROM booking WHERE the... You might return the number of original_availability and the sum of reservation in the same query if you use a LEFT JOIN to the reservation. (A left join is necessary because if nobody has yet booked, there was no result returned by reservation).

Then I'd do the comparison in PHP to see if there are places available, taking into account the number of places required by the current transaction.

Tags: Dreamweaver

Similar Questions

  • How can I insert data from another table into a table containing a timestamp column

    How you insert data from another table in a table if the target table contains a timestamp column. I tried to set the default value of GETDATE() column in the target table, but it does not work.


    I use MS SQL

    Sorry, I managed to get around this by inserting null as the value

  • Populating one table from another table

    Hi Forum...

    I'm trying to populate a table from another table using CFQUERY... I have no problem with the selection of data from the original table, but need help to get the data into the new table. I use MX 6.1 and access as the database server.
    The two arrays have domain names identical to the same place, and I don't want to have to code all the column names in the selection and insert command. for example

    < cfquery name = "GetData" datasource = 'somename' >
    SELECT * FROM AssetTable1 WHERE BarCode = "123456".
    < / cfquery >

    < cfloop query = "GetData" >
    < cfquery name = "InsData" datasource = 'somename' >
    INSERT INTO AssetTable2 (xxxx...)
    VALUES ("#xxxx... #'")
    < / cfquery >
    < / cfloop >

    I hope this makes sense

    Thanks in advance

    Dave

    If your tables are identical structures and their columns are of the same type and position, and both tables are in the same database, then put everything in a single query.


    INSERT INTO AssetTable2
    SELECT *.
    OF AssetTable1
    WHERE bar code = "123456".

    If the columns were in different positions, then you should be listed explicitly in the INSERT and SELECT the parts, but you get the idea.

    INSERT INTO table1 (col1, col2)
    SELECT col1, col2
    FROM table2
    WHERE all that...

    Phil

  • Create a new table from another table which are ussing a stored procedure

    Hello

    I want to know if it is posibble to create a new table from another table which are ussing a stored procedure. This new table is created from another table that exists in the DB.
    (in the following code the table tbl1 exist in the schema of the DB, but temp_tbl1 does not exist, it must be created by the procedure)

    create or replace procedute temp is
    temp_tbl1 tbl1% TYPE; the temp_tbl1 will have the same type of tbl1
    Start
    create the table temp_tbl1 as (select * from tbl1);
    time of the end;
    \


    Thank you very much

    Yes, it is possible to create a table using a procedure.
    Do everything that use dynamic SQL is

    Try this:

    ==================================================
    create or replace PROCEDURE Create Table as
    BEGIN
    EXECUTE IMMEDIATE ' CREATE TABLE testtable in select * from testingtable';
    END createtable;
    ==================================================

    Kind regards
    Ankur

  • Insert values from another table

    Hello I have a table:

    T1
    ---
    ID
    user

    and another table:
    T2
    ---
    intellectual property
    Mac

    So I modified T1:
    ALTER table T1 add ip number (20);
    ALTER table T1 add mac number (20);

    So I have:
    T1
    ---
    ID
    user
    intellectual property
    Mac

    T1 and T2 are the same number of lines.

    Now, I want to insert the values of IP and mac of T2 in the fields ip address and mac of T1.
    IP and mac of T2 fields can be "not null".

    How can I do?

    Thanks in advance

    and what do you think about something like this:

    UPDATE t1
       SET t1.mac =
           (SELECT t2.mac FROM t2 WHERE t2.id = t1.id),
           t1.ip =
           (SELECT t2.ip FROM t2 WHERE t2.id = t1.id)
    

    Give it a shot... validate the results before stolen.

    HTH,
    Thierry

  • Select from another table, when the query returns no result

    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    Thank you.

    user10407139 wrote:
    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    I think you need to explain more clearly if

    -you only have a couple of "billing" columns which is empty and in this case, you want to use the columns from the table 'accounts '.

    - or you have a join with another table that doesn't return data, for example a foreign key "address_id" "billing" is zero and therefore the join to other tables 'address' will return all the data

    In the first case, you have already been provided with some examples here, how to use NVL or similar functions to achieve, even if the first post first evaluates the information of 'accounts' and if it is white using information from "billing". According to your description you need the other way around. The second post a subquery recursive useless in my opinion.

    In the latter case, you should probably use an "outer" join so that the data in your table "bills" are returned, even if the join to another table is not at all the lines.

    SELECT
    NVL(AD1.ADDRESS_ATTR1, AD2.ADDRESS_ATTR1) as ADDRESS_ATTR1,
    NVL(AD1.ADDRESS_ATTR2, AD2.ADDRESS_ATTR2) as ADDRESS_ATTR2,
    NVL(AD1.ADDRESS_STREET, AD2.ADDRESS_STREET) as ADDRESS_STREET,
    ...
    FROM accounts a
    INNER JOIN billings b
    ON a.accountid = b.accountid
    LEFT OUTER JOIN address ad1
    ON b.address_id = ad1.address_id
    INNER JOIN address ad2
    ON a.address_id = ad2.address_id;
    

    In this way you pick up the address stored in the "invoices" table, if it existed, otherwise you pick up the address assigned to the "accounts" table I used an inner for the second address join join because you said that the account always has an assigned address.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • How copy sequences from another project and NOT end up with entries double for source clips?

    If, like me, allowing you to work in Final Cut Pro, you know a major difference in first Pro workflow is that the two projects cannot be opened at the same time. Also, the referenced clips must be part of the project first. Firstly, it forces me to be more organized with projects/clips and avoids the situation of source clips "unregistered". On the other hand, I'm running in a challenge around copy/reuse of sequences from another project.

    We have a large group of images that is used for two different purposes. In order to keep things clear, I created two project files that contain the same elements of sources and the different sequences. (I cloned the project after importing all the clips in the source and work then from there.) Now, I need to "copy" some footage from the project A to project B, so that I can reuse the edition work on these sequences without having to replicate them on the. In FCP, I would have just two projects open and copy - paste the sequences of project A to project B. In Premiere Pro, I was happy to see that copy - paste can work through projects - i.e., I can 'copy' in the project, close the project A open project B, then "Paste". HOWEVER, bringing to all of the source clips referenced by these sequences in the project has... Even if the source clips are already in project B.

    OK, I understand why this happens, because Premiere Pro does not know (or check) the same clips already exist in project B. But I don't want to keep the two entries of the source clips in the project (in different bins too), because that becomes a source of confusion on the road. Is it possible for me to separate the news sequences of these 'new' entries in source clip and connect them with the existing entries? If I just go and delete the entries of 'new' source clip, references in these sequences don't simply go offline, they are deleted. If new sequences are empty.

    I fight to see what is the best approach in this case. Any suggestions or tips?

    I do this very similar workflow. I'll have the project 'A' where I change my sequences, etc., and then down the road, if I want to use some of these project grna 'A' in a new project 'B '.

    PP can do what you are looking for and do not create the duplicate of source even footage items.

    Do not copy and paste. Use rather import to import the discovery of the other project.

    Open your project that you want to reuse sequences. Then go to file > import and place you on the project that you want to import sequences of. Click the project file, and PP will ask you which you want to import sequences. Select the sequences (or the entire project) and PP will import the footage for you.

    Now... the media in double...

    If you clip source "00001.MTS' for example, already in the project you have open and one of the sequences that you import reference also the clip of"00001.MTS"from source, PP will not import a duplicate because it will use the clip that you have already imported.

    However, if PP is to import a copy it's probably because in each project, you have different I/O points set for the same element in source. If this is the case of the PP will import the copy of the clip so it retains every version of the video I/O points.

    If you make a test import and make sure that there is no point of I/O, or they are the same I/O points, PP will import the clip of dup.

  • How to update one column from another table

    Hello

    We have some sellers who are defined as employees but without employee_id for some reason any.  So I would like to update the correct number of a view of HR records.  Here is what I tried:

    update of po.po_vendors x

    Define employee_id = (select apps.per_people_v7 person_id y)

    where y.first_name |' '|| y.last_name = x.vendor_name)

    Error received: a row subquery returns more than one line.

    If I use this instruction to check, I'm correct employee_id or person_id home:

    Select apps.per_people_v7 person_id y, po.po_vendors x

    where y.first_name |' '|| y.last_name = x.vendor_name

    When I checked/compared with some old posts here, I could not just see where I did mistake.  Please notify.

    Thank you

    Ning

    Because for the same vendor id, you have a (employee id) id of the person twice in the target table. As Boneist said "fix data, difficulty of the request, fix the requirement...". »

    How many sellers are there in your target table?

  • How to update one table from another table

    Hello

    I have two tables, t1 or t2, I wrote the below query, but got an error as ORA-00904 ' identifier Inavlid b.purchase_capturedate. The query is:

    Update t1 a
    Set a.docdate = b.purchase_capturedate
    where (a.docid))
    Select docid_request from t2 b where a.docid = b.docid_request and b.itemcategoryid = 6)



    Help, please.


    Kind regards

    Hello

    describe your tables t1 and t2

    Concerning
    Sankar MN

  • How to publish a data in the table from another table

    Oracle forms6i

    Hai All

    I created a form in order to generate traffic. I had a problem that I can post that two data

    I have two tables, a table is created dynamically the data in the tables are extracted from the text file, and they are divided and stored fields are

    Bartime Bardate barcode

    000011 0815 01/08/2010 - it came

    000012 0816 01/08/2010

    000013 0815 01/08/2010

    000011 1130 08/01/2010 - he goes for a break

    000011 1145 01/08/2010 - it comes once again in

    000011 1650 01/08/2010

    000012 1655 01/08/2010

    000013 1645 08/01/2010 - it home

    That I need to transfer this data to the database table, the table name is dail_att and the fields are
    Code bars, timein, timeout, breakin, escape, day like I need like this

    Barcode Timein Breakin Breakout Timeout Attend_date

    000011 0815 1130 1145 1650 01/08/2010

    I tried to use some service number and rank of count, but it does not work Pls I give good solutions

    The encoding is


    declare
    The CNT number;
    bar_code varchar2 (25);
    date of bar_date;
    in_time varchar2 (25);
    out_time varchar2 (25);
    intr_intime varchar2 (25);
    intr_outtime varchar2 (25);

    Cursor c1 is
    SELECT count (*), barcode, bardate, bartime
    -ROW_NUMBER() over (order by bartime) RN
    of temp_attendance
    Group of barcodes, bardate, bartime

    order by bardate;
    Start
    To r1 c1 loop
    -Select the barcode, bardate, bartime
    -ROW_NUMBER() on the partition by barcodeorder by bartime: nurse
    -of temp_attendance
    -the Group of barcodes, bardate, bartime
    -order by bardate;

    If (cnt < = 1) then
    Select the code bar, intimate, intrtimein, introuttime, outtime, attend_date in bar_code, in_time, intr_intime, intr_outtime, out_time, bar_date from dail_att where attend_date = r1.bardate - 1;

    Update dail_att set outtime = r1.bartime where attend_date = r1.bardate and barcode is r1.barcode.;
    elsif (cnt < = 2) then
    insert into dail_att(barcode,attend_date,intime,outtime)
    values (R1. Barcode, R1.bardate, min (R1. Bartime), Max (R1. Bartime));
    -other
    -update dail_att set outtime = r1.bartime where attend_date = r1.bardate and barcode is r1.barcode.;
    end if;

    End loop;
    forms_ddl ('commit');
    exception
    while others then
    forms_ddl ('rollback');
    message(SQLERRM|| dbms_error_Text);
    message(SQLERRM|| dbms_error_Text);
    End;




    Thanks and greetings

    Srikkanth.M

    You seem to always have the same problem, but give it different titles. It would be much easier that you would hold a thread open until its resolved. The last time you had this problem that I posted the following code, it didn't help you? (Replace x and y in each if or ELSIF with the calendar you want to watch)

    CURSOR cr IS
      SELECT CODE,
             DATE,
             TIME
        FROM FROM TEMP_ATTENDANCE
       ORDER BY CODE, DATE, TIME;
    BEGIN
      FOR rec IN cr LOOP
        IF rec.TIME BETWEEN x AND Y THEN
          -- Update record for last day
          ..
        ELSIF rec.TIME BETWEEN x AND Y THEN
          -- Update record
         ..
        ELSIF rec.TIME BETWEEN x AND Y THEN
          -- Update record
         ..
        ELSIF rec.TIME BETWEEN x AND Y THEN
          -- Update record
         ..
        ELSIF rec.TIME BETWEEN x AND Y THEN
          -- Update record
         ..
        ELSIF rec.TIME BETWEEN x AND Y THEN
          -- Update record
         ..
        END IF;
      END LOOP;
    END;
    
  • How can I update this table with values from another table?

    Hello

    I have a table 'governed '. I want to replace the values in the column "regies.agent" by the value of the column "regies_personnes.id."
    As you can see the tables have a column of common values. IE regies.agent = regies_personnes.nom

    Table 'governed ':
    Insert into 'authorities' (AGENT) values ('Humberdot Alain");
    Insert into 'authorities' (AGENT) values ("Danard Patrick");

    Table 'regies_personnes ':
    Insert into REGIES_PERSONNES (NAME, ID) values ("Humberdot Alain", 1);
    Insert into REGIES_PERSONNES (NAME, ID) values ("Danard Patrick", 2);

    Before having it
    SQL > select agent of authorities;
    Humberdot Alain
    Patrick Danard

    After the update, the result should be
    SQL > select agent of authorities;
    1
    2

    Thank you for your kind reply.

    You can

    update regies r set agent = (select id from regies_persones p where r.agent = p.nom)
      where exists (select id from regies_persones p where r.agent = p.nom)
    
  • How to perform an addition of column values in an insert query that would insert in the 3rd column, and the values how to insert into another table.

    I have two tables (2) RESULT TAB (1)

    CREATE TABLE TAB

    (

    NUMBER OF SNO

    A NUMBER,

    B THE NUMBER.

    NUMBER OF THE SUM

    );

    CREATE AN ARRAY OF RESULT

    (

    NUMBER OF SNO

    NUMBER OF THE SUM

    )

    my doubt is:

    (1) I want to insert a table TAB, my question is how to insert a column to the SUM using the column A AND B... Here im adding two values of the column and store result in the AMOUNT column.

    SNO   A  SUM           

    1 100 150 250

    2 300 100 400

    I want to like this, it is possible with single insert query?


    (2) at the time of the insertion TAB of values that SNO, and the values of table TAB $ insert in the table of RESULTS... is it possible these two inserts at the same time?

    in fact, im using another this table.fro TAB and easy to understand I write like that, please solve this problem

    First, you post in the wrong forum as this one is only for Oracle's SQL developer tool. So you might ask your question in the general forum of SQL.

    Second, you might solve your problems with bind variable:

    Insert tab

    (sno, a, b, sum)

    values

    (: SNO,: A: B: A + B :))

    You should not use sum as column name because it is a reserved word.

    More you cannot insert into two different tables with a single SQL, but you can use PL/SQL to do this:

    Start

    insert into tab values (: SNO,: A: B: A + B :);)

    insert into result values (: SNO,: A + B :);)

    end;

    If you meet sno from a sequence, you could do something like this:

    Start

    insert into values tab (seq_sno.nextval,:,: B,: A +: B) return sno in: SNO.

    insert into result values (: SNO,: A + B :);)

    end;

    Hope that helps,

    dhalek

  • The default value based on the field from another table to a custom object

    I'm trying to set the default value to a field in the custom object to the value of a field of account. I tried the syntax 50 ways different and just don't get the case. The label for the account field displays the form of s/n, the integration of the tag is ltDBA_ACCT and it appears in the fx reports area as Account.Text_22.

    The field of custom object that I am triying update is also called s/n, which was originally the required field 'NAME '. The name of the table, account, should it be included? Do I need a function to the field?

    I've updated the external ID using the line with syntex < ID > ID (at least higher ID) so I know that it is possible to define a default value, but s / < n >, < ltDBA_ACCT >, 'account '. "" S/n "and so on are simply not working.

    If anyone knows how to get into what I would be really grateful for the help.

    OK, so if you default a field to the value of another object, you must use the JoinFieldValue function. I think you understand that, based on your original post, but I want to be sure you do.

    Then this won't work by default if the folder is created from the object that you want to join the because a default works in record creation and the ID must be available so that it works correctly. It will not work if you choose the record of the related object after that registration of the custom object is created. You can set the default after, but that does not meet your requirements.

    The syntax of the default are the following: JoinFieldValue (ref_record_type, foreign_key, field_name).

    In your case, ref_record_type is '', foreign_key is [] and field_name is ''. The best way is to determine what is the name of the field to create a new workflow for the account and use the Workflow Rule Condition expression builder to choose your field ("DBA") in the list. The value returned by the expression builder must be placed in the field_name variable in the function JoinFieldValue (minus the parentheses and quotes).

    Give it a shot and let me know how you do.
    Thom

  • update of data from another table

    Hi, I would like to help. I Don t know how I can start doing:


    I have a table with a column with numbers (primary key) and I need to create another column with the same values,


    I want to change a table that has only numeric values (PK) to another
    value, so I disable the constraints of linked tables
    then I create another column that I called the "d" column and copy the values
    from column A to column D

    For example.

    TABLE XYZ

    COLUMN A: COLUMN D: (NEW)

    00001 00001
    00002-00002
    00003-00003
    00004 00004


    Can I change the values in column A and D of the column will be kept

    TABLE XYZ
    COLUMN A: COLUMN D:

    00001 99901
    99902 00002
    99903 00003
    99904-00004


    As the tables that must "point" to the column, I change the values with the new numbering

    TABLE ZZZZ

    COLUMN B: (the values of the column before the change)

    00001
    00002
    00003
    00004
    ...

    I want it like this:

    99901
    99902
    99903
    99903
    99904
    ...


    In other words, I find the current value in column D of the XYZ table for the new value that is in column a.



    I appreciate the help! :)

    Try this
    Here you will find a record in test1 for a record for each line of teste2 in teste2 joined the condition t1.numer_documento2 = t2.numero_documento.

    This is called as subquery related Co. What you were doing was under queries that and not to join the top request.

    UPDATE teste2  t2 SET NUMERO_DOCUMENTO =
    (SELECT T1.NUMERO_DOCUMENTO
      FROM teste1 t1
      WHERE t1.numer_documento2 = t2.numero_documento
      and ROWNUM = 1 )
    
    -- "Check/Select your data before you commit "
    

    SS

  • How publish data from the table with some data loss all post in the forum

    I wonder how people are displayed the data in the table or the result of a query with losing them its format from Sqlplus display when they post in the forums of Oracle. I searched on the basis of knowledge of DB but I see no article about it. can you please help me or direct me to this link, I tried different options using code and other tags but nothing has worked, thank you for your help. Thank you.

    Edited by: Ariean October 3, 2011 12:34

    You can click on the link to the FAQ at the top right: http://wikis.sun.com/display/Forums/Forums+FAQ.

Maybe you are looking for

  • Continuous restart after installing updates on windows xp

    Hi, I have an Acer Netbook only a year and I installed the automatic Windows updates because my windows is original, so I thought that it would be no problem. The thing is that a few days before he installed the latest update and after the reboot to

  • Problems with Fuze + and new 32 GB Sandisk microSD card class 4. CAVEAT!

    I bought this card on Amazon.com and it was listed as a card MicroSDHC card SDSDQ - 032 G-A11M us retail package. This was announced as a class 2 card, but the card is labeled as a class 4 card and it's true that the write speed of this card on avera

  • How to get operational Task Scheduler?

    In the event viewer, I can see the next event, which appears after every start. Service Task Scheduler doesn't have to launch tasks triggered by starting the computer. Additional data: error value: 2147942402. User action: restart the Task Scheduler

  • Wireless devices cannot connect to each other using the router EA6900

    I use the 2.4 Ghz network and none of my wireless devices are able to communicate with each other...  I could not connect to a wireless printer to my laptop wireless (through the router) and thought it was unusual.  I tried ping does not work either.

  • The object has in anticipation of m: n tasks of commissioning

    Synchronization log shows "the object (grp_name) (LDAPGroup) has been ignored during synchronization. "Reason: the object is in the expectation of m: n tasks of commissioning. In which tables are found these pending tasks? Thank you!