Hi all...
Can anyone give clue in doing below?
Let say i have a table A with the following 3 fields. 1)Date
2)Title 3)Status.
i need to insert into table B (also have the same 3 fields) from this
table A with the condition where Title is "Alarm" and Status is "ON".
This can be done by a simple "INSERT" query.
However, there's a case for table A in like below:
Date Title Status
------ ------ ----------
5/7/07 1:05:23am ALARM ON
5/7/07 1:05:24am ALARM ON
5/7/07 1:05:25am ALARM ACK
5/7/07 1:05:25am ALARM ON
Based on the table A above, i only need to insert from table A into
table B the first 2 ALARM(ON)s. The third ALARM(ON) which has the same
Date with ALARM(ACK) needs not to be inserted into table B.
How can i write a simple SQL query which can insert all ALARM(ON)s
which doesnt have same date with ALARM(ACK)?
Thanks. Pls help.
Albert 1 8724
albertleng wrote:
Let say i have a table A with the following 3 fields. 1)Date
2)Title 3)Status.
I trust that these aren't the real column names. Celko will likely
come along later today and post his usual lecture.
i need to insert into table B (also have the same 3 fields) from this
table A with the condition where Title is "Alarm" and Status is "ON".
This can be done by a simple "INSERT" query.
However, there's a case for table A in like below:
Date Title Status
------ ------ ----------
5/7/07 1:05:23am ALARM ON
5/7/07 1:05:24am ALARM ON
5/7/07 1:05:25am ALARM ACK
5/7/07 1:05:25am ALARM ON
Based on the table A above, i only need to insert from table A into
table B the first 2 ALARM(ON)s. The third ALARM(ON) which has the same
Date with ALARM(ACK) needs not to be inserted into table B.
How can i write a simple SQL query which can insert all ALARM(ON)s
which doesnt have same date with ALARM(ACK)?
insert into B (Date, Title, Status)
select Date, Title, Status
from A a1
where Title = 'ALARM'
and Status = 'ON'
and not exists (
select *
from A a2
where a2.Date = a1.Date
and a2.Title = a1.Title
and a2.Status = 'ACK'
) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dynamo |
last post by:
Hello again
Need some help inserting data into a table using an array.
This works:
$col1 = 2;
$col2 = 2;
$col3 = 2;
$col4 = 2;
$query = "INSERT INTO test (a,b,c,d) VALUES ($col1,$col2,$col3,$col4)";
|
by: Shibu |
last post by:
Hi,
I have a situation where I need to convert business objects to a flat table.
The reverse is also required. I am using c# and
Oracle ODP. I am looking for an easier method to do the below steps.
Steps I follows for populating Business Objects is as follows
(1) Get a list of records containing various tables joined together from DB
using a single PL/SQL
(This is a specific requirement, So cannot change the design)
|
by: swatijogdand |
last post by:
how to insert data in a linked table through a pass through query?
pass through query and linked table are attached to the access database at runtime.Also ,pass through query contains stored procedures.
can it be done without giving 'insert permissions' on stored procedures?
plz help... it's urgent
thx in advance,
swati
|
by: VitaminB |
last post by:
Hi Guys,
I try to insert data from a form into a mysql database, but it did not
work...
There is no error, but the data did not pass thru the table.
This is the short script:
|
by: chitrapu |
last post by:
hiii everybody,
i have a little code that inserts the data into the databse. but the problem is the insertion should be peroformed only when a button is clicked. i have problems in this because i am not able to call the function when the button is clicked. hope anyone can help me out with a good code.
echo"Enter the name :";
echo"<input name='names' type='text'>";
echo"<input type='submit' value='ADD name' align=center><br>";
$link =...
| |
by: servo |
last post by:
I am using the following code. Why it does not insert record in the MySQL Table through php script:
<?php
$dbhost='localhost';
$dbuser='root';
$dbpass='newpass';
$mysqldb='mysql';
if(isset($_POST)){
|
by: troydixon |
last post by:
Hello,
I am new at this, and have been trying to insert data into a table by using the footer of a gridview (which I dont like) or by using a detials view on the same page that is doing the following:
1) gets query string from url and filters records (works great) via a Details View
2) shows notes that have been added to the record shown in the details view using a grid view, and it filters the data by looking at the ID that is selected in...
|
by: gerrybytes |
last post by:
Is the following a vaild query, or does any one have any suggestion on how to change it to get the correct info i'm looking for?
$Engineer = $_POST;
$Ref_No = $_POST;
$query = "INSERT INTO engineer (Ref_No,Title,Forename,Surname,Email,Branch,Message,Severity,Engineer)
VALUES('$Engineer')
SELECT Ref_No,Title,Forename,Surname,Email,Branch,Message,Severity FROM new_fault
WHERE ref_no='$Ref_No'";
|
by: ddtpmyra |
last post by:
I don’t know if I posted my question on the right forum if not my bad, but I’m having trouble how to create a php script that will insert data on mysql
Scenario:
I have 3 checkbox on my form and users select all
Checkbox1
Checkbox2
Checbox3
Table structure:
Date, checknames
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |