473,320 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to write select query and insert query at the same time

Sir,
how to write select query and insert query at the same time. I have one database that db having six field. waiting for your reply.

thanking you
Oct 24 '07 #1
5 7692
r035198x
13,262 8TB
Sir,
how to write select query and insert query at the same time. I have one database that db having six field. waiting for your reply.

thanking you
Describe what you want to achieve and tell us the database you are using as well.
Oct 24 '07 #2
realin
254 100+
Do this in two different steps.. first execute the select query and then execute the insert query using the same mysql_query function. Also i believe if u want to edit the existing data(cause u demanded select and insert combo), then you need use UPDATE command, instead of insert

SAMPLE would be
[PHP]
$sql1="select * from mytable";
$con=mysql_query($sql1)
if($con){
$sql2="insert into mytable(column1,column2) values ('value1','value2')";
mysql_query($sql2);

}
else{
echo "Error executing first query";
exit
}[/PHP]

cheers !!
Oct 24 '07 #3
r035198x
13,262 8TB
Do this in two different steps.. first execute the select query and then execute the insert query using the same mysql_query function. Also i believe if u want to edit the existing data(cause u demanded select and insert combo), then you need use UPDATE command, instead of insert

SAMPLE would be
[PHP]
$sql1="select * from mytable";
$con=mysql_query($sql1)
if($con){
$sql2="insert into mytable(column1,column2) values ('value1','value2')";
mysql_query($sql2);

}
else{
echo "Error executing first query";
exit
}[/PHP]

cheers !!
I wouldn't call that writing the select and insert queries at the same time but we'll have to see if that's what the OP wanted.
Oct 24 '07 #4
i have the same problem where i have two form,first form recieve data from serial port and insert these data into database,the second form select data from
the same database during the first form is inserting.whene i open second form
and select some data as a result hang.

need help urgent.
thanks
Alaa
Nov 1 '07 #5
code green
1,726 Expert 1GB
the second form select data from
the same database during the first form is inserting.whene i open second form
You can't really do this.
You need to wait for the first query to finish executing because the new data may not be there yet.
Nov 1 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Phil Powell | last post by:
$sql = 'INSERT INTO fs_usermetadata (' . substr(trim($cols), 0, strrpos(trim($cols), ',')) . ') VALUES (' . substr(trim($values), 0, strrpos(trim($values), ',')) . ')'; if (!mysql_query($sql))...
0
by: lea | last post by:
I have two combobox, I let the user to select report criteria FROM xx TO xx. i have a button call btnPrint to select report criteria and print according to the criteria. I able to SELECT the...
0
by: jtocci | last post by:
I'm having a big problem with CREATE RULE...ON INSERT...INSERT INTO...SELECT...FROM...WHERE when I want to INSERT several (20~50) records based on a single INSERT to a view. Either I get a 'too...
1
by: suslikovich | last post by:
Hi all, I am getting this error when insert values from one table to another in the first table the values are varchar (10). In the second they are datetime. The format of the data is mm/dd/yyyy...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
2
by: Himmel | last post by:
Hello! The reference database I currently use runs queries that pull data from hundreds of tables in order to create user-friendly form view. The problem is that these queries can take upwards of...
12
by: =?Utf-8?B?Smlt?= | last post by:
I have code that reads and parses a text file using a schema.ini file. Works great. When I see the dataGrid it's exactly what I want. Dim CString As String = _...
0
by: bozzzza | last post by:
Lets say we select from TableA that joins to TableB TableB also gets data inserted into into it via another query. So I guess SQL server places a shared lock on Table A and Table B. and the...
36
by: CK | last post by:
How do I write a set based query? I have a groupSets table with fields setId, idField, datasource, nameField, prefix, active Data: 1,someIDfield, someTable, someField, pre1, 1 2,someotherIDfield,...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.