Databases :: Update Multiple Column Using Sub Query?
Apr 1, 2011I want to update multiple column of a table using subquery ...My sample code is shown below
[Code]....
its throwing syntax error...I dont know where i commiting mistake.
I want to update multiple column of a table using subquery ...My sample code is shown below
[Code]....
its throwing syntax error...I dont know where i commiting mistake.
Not sure how to best accomplish this task. I do have several reports to make in Excel every day. The reports do have a shhet for every week and one column for each day in week. What is the best way to get the excel auto update and get data from the SQL table? As for now I run a query on a webpage and coying the data in to the excel sheet manually. Should I try making a database connection within the excel sheet? Should I try having a ADO connection working in .NET? I really don´t know where to begin.
View 2 RepliesI have to update multiple row and two column of each row.
I have try to Update with case statement but after I perform that statement it blank out every other column that doesn't fall into the criteria of the update statement.
My table structure is like this;
table1
col1
row1 11
row2 22
I want to update row1 and row2 of their col1 in one single sql , how do i do that?
Heres the situation: I need update a column from my table (T1) from two other columns in a different table (T2).
My constraints are:
That I have to match the first 4 letters of a column in T2 to one column in T1 I have to identify that the first letter in a column in T1 corresponds to one letter in the middle of a string in a column in T2 For instance:
My Table (T1):
Order Type Combined
Place
0090 0001 YYXX 1YY
0091 1001 YYXX YYY
0092 1002 XXXX 2XX
Table 2 (T2):
Order Value
00900001YY XX
00911001YY XX
00921002XX XX
The Combined column in T1 is what i'm trying to complete. The T1.Place column contains the first character that I want to check for.
If it's a "1" then I want to make sure the 5th letter in T2.Order is a "0" If its a "Y" then I want to look for a "1001" If its a "2" then I want to make sure the 8th letter is a "2" in T2.Order
If all that matches then I was the last two letters in T2.Order + T2.Value to be combined and put into the appropiate spot in T1.Combined
Here's what I have:
[Code]....
I know it's a little complex, but i'm really stuck on it and any help would be greatly appreciated.
I use Mysql database, in this i create two table A, B. table A column x and is FK of second table B's column m,n,o provide does it possible that x referncing to foreign key of table B columns m, n , and o all.
View 2 RepliesI need to insert/update data to 3 or more tables on a single button click.What is best method for achieving this?I am using mysql as my DB.
View 2 RepliesI am a biggner in SQL DB . but i started a complicated and painfull work in SQL SERVER 2008. the problem convert Oracle hierarchical query to SQL query. the query
SELECT DISTINCT
LEVEL LVL,
SCH.NSCHEDULE_SL,
SCH.NSCHEDULE_SL_FM,
SCH.CSHED_CNAME
FROM FA_SCHEDULES SCH
WHERE LEVEL = 1
AND NSCHEDULE_SL_FM IS NULL
AND NBRANCH_SL = 2
CONNECT BY PRIOR SCH.NSCHEDULE_SL_FM = SCH.NSCHEDULE_SL
AND NBRANCH_SL = 2
i want to develop a data access layer ,it can support multiple database like oracle ,Mssqlserver and Mysql using enterprise library and C#.net 3.5 based on database connection
View 1 RepliesI am trying to design my logic to do this but I want to create a dataSet which will have records from several databases, The records all have the same layout.
I am reagin the connection string paths from a table in a database.
I am asking for your help in trying figure out my logic.
Should I use the connectionString builder in conjunction with a loop to Connect, read a record into a dataset Until therer are no more records to be read from my databse table with the database name/paths tables ?
Here is my beginning code which deals with one database:
[Code]....
[code]...
This query works perfectly on the query analyser.
But when configuring the Table adapter ,I try executing the query and i get 0 rows affected.
What could I be getting wrong in this case.
NB:Existing GalleryID has been supplied.
A follow up question concerning the DAL layer part .. The first question about dealing with large objectsI have one table (PlacesTable) that is connected by like 6 other tables (1:Many and Many:Many relations)
In my DAL should I put a big query that join the 6 tables + the m:m reference tables (btw it produces multiple data that I don't need Please refer to my old question) and place all the data in it's specific object property or, should I use a single query for each table and create an object for each fetched table .. and finally send those to the UI ?If I wasn't clear enough please let me know what I further information do you need to know!
I have a table converted from Access and the identity keys were lost. Now I need to make the id column the identity column, but it already has a lot of null values, how do I auto generate integer values for the null rows? The row ids are incremented, so if there is a way to auto increment the ids
View 7 RepliesHere is the sqldatasource config code: <asp:SqlDataSource ID="SqlDataSource1" runat="server"
View 1 RepliesI need to insert values from the frontend into a mysql table. I am using a 3 layer architecture. the below is the code that is written in my dataaccess layer. the query is not being executed.
public int Insert(List<EmployeeUInfo> objInsert)
{
try
{
DataTable dtInsertRow = new DataTable();
[Code]....
Trying to modify an existing gridview in an aspx to access a db2 table on an iseries server. The iseries seems to have problems with the parameter specified in the query as @parameter giving a @parameter does not exist in table error. When specifying the gridview in VS the wizard did not recognize that the @parameter was a parm and prompt for the control etc. where it could be found. Of course there is no problem when accessing a mssql server table. Can someone help me with how to connect properly to the iseries and how to pass a parm on my query?
View 1 Replies[code]....
Im trying to update my DB(DataBase) by using SQL UPDATE query ,but its not updating in the dataBase i receive confirmation(in testLabel) that one row is affected(dataReader = query.ExecuteReader(); return numbers of rows affected)...
I have given a HTML editortext control on a page,which generates HTML (i have to store it in my DB,that page is only for Admin) ,on pressing Update button , im receving in my testLabel that one row is affected(which shows DB is updated succesfully) but when i check my DB its in old state,it is not updating...
Here is my Event handler of Update Button which have to make updates in DB:
[Code]....
[Code]....
I have a question in gridview, I want to combine my two or more records into a single cell with two rowsfor Example i have a ID, Name, Year Start, and Year End for Column name in database and i want call it into my gridview that the Year Start and Year End will combine to Year like:
In Database
ID Name Year Start Year End
1 Yourname 2010 2015
In Gridview:
ID Name Year
1 Yourname 2010 2015
in a year column i want it to two row..
i have a SQL Query. It works fine in Sql server. let me know how to make it work in Oracle.
You can run below code in Sql server and check. It will work fine. But in Oracle,( I am using TOAD for Oracle )it is giving some errors.
Code]....
I need to find out the query execution time from the front end .Where should I insert the code for that.
I am using the bleow query:
OracleConnection con = new
OracleConnection(ConnStr);
con.Open();
OracleCommand cmd =
new
OracleCommand("Stored_Proc",con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add();
....................
................
OracleDataAdapter
oda = new
OracleDataAdapter
(cmd);
when i am executing a simple query it is takeing 47 sec .... that is only for one table.. other then that remaing table perfromance is good... Help me out... and is there chance to get good perfomance through .net coding..
View 3 RepliesI am trying to do a SELECT ... WHERE ... IN construct, using a parametrized query with Oracle (odp.net) and I cannot make it work correctly.
[Code]....
The STATUS column is NUMBER(2) in the database. My problem seems to be related to getting the correct OracleDbType. I've tried Varchar2, Long, Decimal... nothing works. Should I go for the ArrayBindSize construct?
I run queries in my stored procedure and pass values to it as a perameter e.g.
SELECT p.Profile_Id
FROM Profile p
WHERE (p_Gender = p.gender_id)
now is there a way that i can get the actual query executed with paramaters value like this:-
SELECT p.Profile_Id
FROM Profile p
WHERE ('M' = p.gender_id)
I have a the following code to get data from an oracle database using
a parameterized query:
conn = New OracleConnection(connectionstring)
comm = New OracleCommand("select name from Cust_name
from Name_Table Where last_name = :lastname", conn)
parmLastName = New OracleParameter("lastname", OracleDbType.Varchar2)
parmLastName.Value = "Jones"
comm.Parameters.Add(parmLastName)
I am trying to write an audit that will tell me what users are doing, so I would like to get the actual sql that is submitted. This is just one example of the query, there are many more so I would like to make it as general as possible. I would like to actually see "
select name from Cust_name from Name_Table
Where last_name = "Jones". I know I could just create the text
I am generating page number for my listview control. I am using mysql as databast. Please check the sysntex it is giving error but works fine with sqlserver.Public Function GetPageNumber(ByVal PhotoID As Integer, ByVal AlbumID As Integer) As Integer
Dim con As New MySqlConnection
con.ConnectionString = "server=localhost;User Id=root;database=jis;password=papidm;Persist Security Info=True"
[code]...
This is the code. The error giving in the Mysql query syntex heighlighted
I want to bind three column with one row in gridview in asp.net with c#,
i want like this,Â
Name | Info
----------------------
name | lastname
    | phone number
    | address
I get this by default
name | last name | phone number | addressÂ