How can update two rows in one query?

How can update two rows in one query?
Edited by: OracleM on May 4, 2009 12:16 AM

What do you mean with "two rows"? May be two columns??
If the where clause of UPDATE query matches two rows, then it will update two rows. If you want to update two columns, then add column names to your query
UPDATE your_table SET col1=value1, col2=value2 WHERE your_where_clause- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

Similar Messages

  • How to update multiple rows in one query using php

    i am new to this can any one help me how to update multiple rows at a time i am doing an school attendance page

    Often the situation is such that you have multiple courses across a range of dates.So students may take more than one course, and you need to track attendance for each course date. The following graphic demonstrates this:
    In such a situation, you need four database tables as follows:
    students (student_id, student_name, etc.)
    courses (course_id, course_name, etc.)
    students_courses (student_id, course_id)
    attendance (student_id, course_id, dater)
    A fifth table may also be needed to define the dates of courses, but you may also be able to build this array programmatically by using PHP's robust date functions, which can give you, for instance, all the Tuesdays and Thursdays between a start date and end date.
    The students_courses table simply keeps track of which students are taking which courses, so it has just two columns for the primary keys of both of the main tables. The attendance table is similar, but it also includes a date field. The following view of the attendance table demonstrates this:
    So if David's solution does cover your needs, consider yourself lucky, because this could quickly grow from a beginner-appropriate project to a moderately advanced one.

  • How to club two rows into one

    hi
    Can we club two rows of a SQL statement into one , that is some column results from one row and other column result from second row, but the row must remain same .
    thanks
    imran

    SQL> with sample as (select 'A' supplier, 1000 total, 0 branch_total from dual
      2                union all
      3  select 'A' supplier, 0 total, 500 branch_total from dual
      4                union all
      5  select 'B' supplier, 300 total, 0 branch_total from dual
      6                union all
      7  select 'B' supplier, 0 total, 120 branch_total from dual)
      8  SELECT SUPPLIER , SUM(TOTAL) , SUM(BRANCH_TOTAL) FROM SAMPLE
      9    GROUP BY SUPPLIER
    10  /
    SUPPLIER SUM(TOTAL) SUM(BRANCH_TOTAL)
    A              1000               500
    B               300               120

  • I have two apple id's because my hotmail account is no longer active. How can I delete the old one and use or update the new one?  Every time I try it won't allow me and now my iPad thinks there are two accounts and they are arguing with each other. Help!

    I have two apple id's because my hotmail account is no longer active. How can I delete the old one and use or update the new one?  Every time I try it won't allow me and now my iPad thinks there are two accounts and they are arguing with each other. Help!

    You can't merge accounts or copy content to a different account, so anything that you bought or downloaded via the old account is tied to that account - so any updates that those apps get you will only be able to download via that account. You can change which account is logged in on the iPad via Settings > Store

  • Update SAME column name in two tables from ONE query

    Dear All Seniors
    Please tell me is it possible to update a same column name in two tables.
    I have two tables in same schema
    (1)table name
    pem.igp_parent
    column name
    igp_no.
    igp_type
    (2)table name
    pem.igp_child
    column name
    igp_no.
    igp_type
    i want to update igp_no column in one query please tell me how it would be possible.
    thanks
    yassen

    You want to update the data from what to what? Where is the new data coming from?
    If you are trying to put the same data in two different tables, that strongly implies that you have a normalization problem that needs to be addressed.
    Why do you want a single query rather than updating each table in turn? Can you join the two target tables to produce a key-preserved view?
    Justin

  • Can you really update two tables in one SQL statement

    Ok a post in the forum has got me awefully curious:
    Can you update two tables in one update statement i.e something like this
    update table a , b
    set b.<column> = something
    a.<column> = something
    Something to this effect.
    If you are curious to know what post I am talking about it is called "updating a single row"

    No. You can only update one table in one SQL statement.

  • TS3981 After migration files are now shared between two user accounts. How can I combine them into one account?

    After migration, from PC, files are now shared between two user accounts.I have to switch users to access files. How can I combine them into one account?

    See Pondini's  Transferring files from one User Account to another, for starters

  • I downloaded pictures onto my iPhone from computer twice by mistake now when i uncheck/sync then check and sync again  i keep getting two lots of pics..how can i get just the one set again? thnx

    I downloaded pictures onto my iPhone from computer twice by mistake now when i uncheck/sync then check and sync again  i keep getting two lots of pics..how can i get just the one set again? thnx

    You're welcome.
    All photos transferred from your computer are stored in the iPhone's Photo Library regardless if you select a single album or folder of photos to be transferred or multiple albums or folders. The photos on the albums or folders of photos include a pointer to the original photos stored in the Photo Library. The photos are not duplicated taking up double the storage space. This way you can view the photos in an album or folder of photos only by selecting the album or folder, or all photos in all albums or folders by selecting Photo Library.
    Makes more sense when transferring multiple albums or folders of photos which cannot be changed when transferring only a single album or folder of photos.
    The same applies with iTunes and music playlists. A song can't be in a playlist unless it is in the main iTunes library. Placing a song in a playlist does not duplicate the song.

  • HT1491 I have two itunes accounts with different Apple ID's.  How can I merge them into one?

    I ahve two itunes accounts with different Apple ID's.  How can I merge them into one account?

    Apple has no provisions for this. You cannot merge multiple Apple ID's into one ID. Content is always tied to the Apple ID that was used to purchase it.

  • HT1414 I updated my i phone 4 to the new version but i want the old one how can i have the old one back

    I updated my i phone 4 to the new version but i want the old one how can i have the old one back. Thank you

    Sorry, Apple has no approved method to downgrade the version of iOS on your iDevice. You can voice your displeasure with the iOS by leaving feedback at the appropriate subsection from the link below.
    http://www.apple.com/feedback/

  • I need to deactivate two old computers and reinstall CS3 on two new computers. How can I do this if one is long gone and the other just crashed?

    I need to deactivate two old computers and reinstall CS3 on two new computers. How can I do this if one is long gone and the other just crashed?

    contact adobe support and request an activation count reset, http://helpx.adobe.com/x-productkb/global/service1.html

  • List aggregate two rows into one

    query :
    select kod_negeri.NAMA kod_negeri_nama,
    hakmilik.id_hakmilik,
    MOHON.PENYERAH_NAMA,
    MOHON.PENYERAH_ALAMAT1, MOHON.PENYERAH_ALAMAT2, MOHON.PENYERAH_ALAMAT3,
    MOHON.PENYERAH_ALAMAT4, MOHON.PENYERAH_POSKOD, MOHON.PENYERAH_KOD_NEGERI,
    MOHON.PENYERAH_NO_RUJ, MOHON.ID_MOHON, HAKMILIK.KOD_HAKMILIK, HAKMILIK.NO_HAKMILIK,
    KOD_LOT.NAMA, HAKMILIK.NO_LOT, KOD_BPM.NAMA, KOD_DAERAH.NAMA,
      LELONG.TMPT, LELONG.DIMASUK, PGUNA.NAMA,
      PIHAK.ALAMAT1, pihak.NAMA ven,
    PIHAK.ALAMAT2, PIHAK.ALAMAT3, PIHAK.ALAMAT4, PIHAK.POSKOD,
    mohon.id_mohon ,
    pguna.NAMA pguna_nama,
    pguna.JAWATAN,
    kod_daerah.NAMA kod_daerah_nama,
    to_char(enkuiri.TRH_enkuiri,'DD')||' '|| to_char(enkuiri.TRH_enkuiri,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (enkuiri.TRH_enkuiri, 'YYYY') trh_enkuiri,
    to_char(lelong.TRH_lelong,'DD')||' '|| to_char(lelong.trh_lelong,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (lelong.TRH_lelong, 'YYYY') trh_le,
    to_char(lelong.trh_lelong, 'Day') day,
    to_char(lelong.TRH_lelong,'HH12:MI ')  hour,
    DECODE(SUBSTR(to_char(lelong.TRH_lelong,'HH12:MI AM'),-2,2),'AM','Petang','pagi')  noon,
    enkuiri.cara_lelong,
    lelong.TMPT,
    lelong.HARGA_RIZAB,
    enkuiri.harga_rizab,
    initcap(pihak.NAMA) pihak_nama,
    initcap(lelong.EJA_RIZAB) er,
    'RM'||enkuiri.TUNGGAK_AMAUN,
    lelong.DEPOSIT,
    convert_number_words(lelong.DEPOSIT) as converted_form,
    to_char(lelong.TRH_AKHIR_BYR,'DD')||' '|| to_char(lelong.TRH_AKHIR_BYR,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (lelong.TRH_AKHIR_BYR, 'YYYY') TRH_AKHIR_BYR,
    to_char(sysdate,'DD') ||' '|| to_char(sysdate,'MONTH','nls_date_language=malay') ||' '||to_char(sysdate,'yyyy') sysd,
    kod_bpm.NAMA kod_bpm_nama,
    kod_lot.NAMA kod_lot_nama,
    hakmilik.NO_LOT,
    hakmilik.KOD_HAKMILIK,
    hakmilik.NO_HAKMILIK
    from
    mohon ,
    mohon_hakmilik ,
    lelong ,
    pguna ,
    pihak ,
    kod_daerah ,
    enkuiri ,
    kod_bpm ,
    hakmilik ,
    kod_lot ,
    kod_negeri,
    mohon_fasa ,
    kod_hakmilik
    WHERE mohon.id_mohon = mohon_hakmilik.id_mohon and
    mohon_hakmilik.id_hakmilik = hakmilik.id_hakmilik and
    hakmilik.kod_hakmilik = kod_hakmilik.kod(+) and
    hakmilik.kod_lot  = kod_lot.kod(+) and
    hakmilik.kod_bpm = kod_bpm.kod(+) and
    hakmilik.kod_daerah = kod_daerah.kod(+) and
    mohon.id_mohon = enkuiri.id_mohon and 
    lelong.id_pihak = pihak.id_pihak and
    lelong.id_mh = mohon_hakmilik.id_mh and
    pihak.kod_negeri = kod_negeri.kod(+) and
    mohon.id_mohon = mohon_fasa.id_mohon and
    mohon_fasa.id_aliran ='semakan' and
    mohon_fasa.id_pguna = pguna.id_pguna and
    mohon.id_mohon = :p_id_mohon
    and enkuiri.KOD_STS='AK'
    and mohon.id_mohon ='0405AUC2010007436'KOD_NEGERI_NAMA,ID_HAKMILIK,PENYERAH_NAMA,PENYERAH_ALAMAT1,PENYERAH_ALAMAT2,PENYERAH_ALAMAT3,PENYERAH_ALAMAT4,PENYERAH_POSKOD,PENYERAH_KOD_NEGERI,PENYERAH_NO_RUJ,ID_MOHON,KOD_HAKMILIK,NO_HAKMILIK,NAMA,NO_LOT,NAMA_1,NAMA_2,TMPT,DIMASUK,NAMA_3,ALAMAT1,VEN,ALAMAT2,ALAMAT3,ALAMAT4,POSKOD,ID_MOHON_1,PGUNA_NAMA,JAWATAN,KOD_DAERAH_NAMA,TRH_ENKUIRI,TRH_LE,DAY,HOUR,NOON,CARA_LELONG,TMPT_1,HARGA_RIZAB,HARGA_RIZAB_1,PIHAK_NAMA,ER,'RM'||ENKUIRI.TUNGGAK_AMAUN,DEPOSIT,CONVERTED_FORM,TRH_AKHIR_BYR,SYSD,KOD_BPM_NAMA,KOD_LOT_NAMA,NO_LOT_1,KOD_HAKMILIK_1,NO_HAKMILIK_1
    Johor,050503PM00000151,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,PM,151,Lot,6309,Mukim Lenggeng,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,ASDFSAF,AHMAD,DSFDS,FDSFSDF,DSFSDF,12345,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ahmad,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Lenggeng,Lot,6309,PM,151
    ,050540HSD00022923,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,HSD,22923,Lot,0009838,Mukim Jimah,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,no2,Ali Bin Abudillah,jalan 3,taman permata,lorong mentari,32333,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ali Bin Abudillah,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Jimah,Lot,0009838,HSD,22923
    KOD_NEGERI_NAMA,ID_HAKMILIK,PENYERAH_NAMA,PENYERAH_ALAMAT1,PENYERAH_ALAMAT2,PENYERAH_ALAMAT3,PENYERAH_ALAMAT4,PENYERAH_POSKOD,PENYERAH_KOD_NEGERI,PENYERAH_NO_RUJ,ID_MOHON,KOD_HAKMILIK,NO_HAKMILIK,NAMA,NO_LOT,NAMA_1,NAMA_2,TMPT,DIMASUK,NAMA_3,ALAMAT1,VEN,ALAMAT2,ALAMAT3,ALAMAT4,POSKOD,ID_MOHON_1,PGUNA_NAMA,JAWATAN,KOD_DAERAH_NAMA,TRH_ENKUIRI,TRH_LE,DAY,HOUR,NOON,CARA_LELONG,TMPT_1,HARGA_RIZAB,HARGA_RIZAB_1,PIHAK_NAMA,ER,'RM'||ENKUIRI.TUNGGAK_AMAUN,DEPOSIT,CONVERTED_FORM,TRH_AKHIR_BYR,SYSD,KOD_BPM_NAMA,KOD_LOT_NAMA,NO_LOT_1,KOD_HAKMILIK_1,NO_HAKMILIK_1
    Johor,050503PM00000151,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,PM and HSD,151 and 22923,Lot,6309,Mukim Lenggeng,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,ASDFSAF,AHMAD,DSFDS,FDSFSDF,DSFSDF,12345,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ahmad,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Lenggeng,Lot,6309,PM,151
    that means i need to list aggregate the two rows into one how to make the changes for the above query in order to do so .
    Edited by: user9093689 on Feb 9, 2011 10:03 PM

    user9093689 wrote:
    now need to bother abt this that line converts date into malay language
    to_char(enkuiri.TRH_enkuiri,'DD')||' '|| to_char(enkuiri.TRH_enkuiri,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (enkuiri.TRH_enkuiri, 'YYYY') trh_enkuiri,iam retriving two rows of output, wat i need is to display one row and the second row values which are not similar should be added to the first row
    for example for column
    kod_hakmilik two rows values are
    PM
    HSD
    but they should be display as
    PM and HSD
    finally my aim is to retrieve only one row as output.
    i dont how exactly the term listaggr . how ever it may be whether using groupby or any other but the output should be as aboveWhat version of Oracle are you on?
    Look up the LISTAGG() function in the documentation for your version (assuming it is there) and see if it can do what you want

  • Update several rows with single query (easy question, I guess)

    Hi all!
    I have table with two columns - name and value.
    I populate it with several sql queries:
    insert into settings (name, value) values ('company_name', 'My Company');
    insert into settings (name, value) values ('company_address', 'Company Address 12');
    insert into settings (name, value) values ('company_city', 'South Park');
    How can update rows with company_name and company_city in single query?
    Thank you in advance!

    How can update rows with company_name and company_city in single query?I guess something like this was meant:
    update settings set value = ??? where name in ('company_name ', 'company_city');But it's still unclear to me what should be used instead of question marks... :)
    Regards.

  • How can we reduce Row Chaining?

    In a 10gR2 db, how can i reduce row chaining in tables?

    Hi,
    First, the prevention techniques for chained rows vs. migrated rows is a bit different. Note that both chained rows and migrated (relocated) rows manifest as "table fetch continued row" in v$sysstat and stats$sysstat for STATSPACK and dba_hist_sysstat for AWR.
    Preventing chained rows - Chained rows can occur when a row is to large for a data block. In these cases, moving large objects into a tablespace with a larger blocksize can often relieve chained rows.
    Preventing migrated rows - Migrated rows occur when a row expands (usually w2ith a varchar2 data type), and there is not enough reserve defined by PCTFREE for the row to expand. In this case, you adjust the PCTFREE to ensure that future rows will have room to expand and reorganize the table to remove the fragments.
    On some tables which are stored tiny and grow huge, you may need to set PCTFREE to a "large" value, so that only one row is stored per block. For example, if I have a row with a varchar2 that is stored at 2k and grows to 30k, I would need to use a 32k blocksize and set PCTFREE=95 so that only one rows is stored on each data block. That way, at update time, there will be room for the row to expand without fragmenting.
    Operationally, Oracle consultant Steve Adams offers this tip for finding the difference between chained and migrated rows:
    http://www.freelists.org/archives/oracle-l/10-2008/msg00750.html
    +"You can tell the difference between row migration and chaining by listing the chained rows with ANALYZE table LIST CHAINED ROWS and then fetching the first column from each "chained row" in a single query.+
    +The count of continued row fetches will be incremented for every migrated row, but not for most chained rows (unless the first cut point happens to fall with the first column, which should be rare)."+
    Hope this helps . . .
    Donald K. Burleson
    Oracle Press author
    Author of "Oracle Tuning: The Definitive Reference"
    http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm

  • How can i add rows in a tabular form

    Hi,
    How can i add rows in a tabular form with out updating in database and after adding the rows one by one and after filling the data then iwant to submit them all at once.Please help me on this.
    Thanks

    Hello Leandro,
    In the Add_Rows page process, there is a box for "Number Of Rows". Change that value and you change the number of rows that get added. The default is 1.
    Don.
    You can reward this reply by marking it as either Helpful or Correct :)

Maybe you are looking for

  • Iphone and outlook not synching

    I was bought an iphone for Christmas and activated it on my home computer. However my up to date diary is on my work computer. I have connected my iphone to my work computer and synched most of my diary entries but each time since it takes a long tim

  • AR and AP upload -T Code F-02.

    Hi Team, Let me know correct approach BDC or BAPI or LSMW for AR AP upload - T Code F-02. Thanks MMV

  • EJB3.0:JPA :java.lang.IllegalArgumentException

    Im pretty new to this, so Im trying to post everything you need to understand my problem,try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic /*Bean class*/ public class BookCatalogBean implements Serializable, Bo

  • System start is not possible. Grey screen and demand for restart

    After power-on I got a grey screen first, after approx. 15 secondes occurs a message "Restart the system". Unfortunately not more happens if I start the system from the HD. I have installed Mac OS X already new, but altrough the installation was suce

  • Satellite U300-111 - Which Windows 7 version you can recommend?

    Hello everyone! I have a friend with a Toshiba Satellite U300-111, and she wants to install Win7 on it. Since it's got a T7100 processor, I'm thinking she could install 64bit version, but it seems like there are far fewer supported drivers compared t