|
can i use a subquery field to my main query.
i.e
select x.field1,y.field2
from tbl1 as x
where x.field3 not in (select y.field3 from tbl2 as y)
|
|
|
|
|
Yes, do be aware that a 'not in' query can be very lengthy if your tables are large.
|
|
|
|
|
thanks,
than what can i do ?
|
|
|
|
|
Sorry - didn't see your reference of y.field2 in the SELECT. Your original query will not work.
You can try a left join:
SELECT
x.field1,
y.field2
FROM
tbl1 x
LEFT JOIN
tbl2 y
ON (x.field3 = y.field3)
WHERE
y.field2 IS NULL
-- modified at 14:37 Friday 10th February, 2006
|
|
|
|
|
thanks, through it i solved my problem.
thanks again.
|
|
|
|
|
try this,may work.
select x.field1,y.field2
from tbl1 as x,tbl2 as y
where x.field3 != y.field3
青山隐隐水迢迢,秋尽江南草未凋。二十四桥明月夜,玉人何处教吹箫。
|
|
|
|
|
The above will work, although you could also just do a normal inner join and use an inequality instead of the usual equality join, instead of the above example with a cartesian product and a where clause.
SELECT x.field1, y.field2
FROM tbl1 as x
INNER JOIN tbl2 as y
ON x.field3 != y.field
|
|
|
|
|
Hi
what is the difference between joins & sub query?
what is the difference between having & compute?
tnx in advance
-ramani
|
|
|
|
|
|
Hi friends,
I have been developed one clien-server application using VB.NET and ADO.NET tech's. I installed my application and MS SQL Server 2000 in server system. but when I am going run the application at Client system it gives the error message as : "Server access denaied" and/or "Unable to connect the server system."
But my application is running perfectly after I installed the Database server at client system without current working datebase.
So I feel that it is required to install the MS SQL server on both server system and client systems. I am not interesting to do in this way.
Kindly, give me the proper solution for problem.
wish me as All The BEST.
|
|
|
|
|
There is no need to install MS SAL SERVER on client end.
Just provide the Server name at the client in your application
server name may be the IP address or the Server name.
|
|
|
|
|
Also install MDAC 2.7 on client machine.
It will definatly work.
Pankaj Kulkarni
|
|
|
|
|
It'll work so long as he built the connection string properly...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm new to SQL, so forgive my ignorance.
I have a number of related tables. Of these there are 3 which are of concern to my problem: Invoices, InvoiceItems and Products. There is a 1:M r/ship between Invoices as well as between Products and Invoice items. The Invoice items table has InvoiceItemID, InvoiceID, ProductID, Quantity and Price.
I would like to add 3 InvoiceItems as records in my InvoiceItems table and i would like to have them related to one Invoice (the last Invoice in my case) in the invoices table, that is, also the field in the InvoiceItems called InvoiceID for these 3 records should have the same InvoiceID. All the Primary Keys are set to AutoNumber.
These are the the statements i used:
INSERT INTO InvoiceItems ( InvoiceID, ProductID, Quantity, Price )
VALUES (4, 8, 1, 0);
INSERT INTO InvoiceItems ( InvoiceID, ProductID, Quantity, Price )
VALUES (4, 9, 4, 0);
INSERT INTO InvoiceItems ( InvoiceID, ProductID, Quantity, Price )
VALUES (4, 10, 2, 0);
I would like to do this using some sort of INSERT SQL statements, but it's just not working. I can INSERT one InvoiceItem, but when i try to INSERT the next one i get some long error saying something about "type conversion failure","key violations", "lock violations" and "validation rule violations"
Does anyone know why this is happening and how to correct it?
Any help would be much appreciated.
|
|
|
|
|
I think you have not entered the master data
ProductID Name
8 ABC
InvoiceID Invoice Name
4 ZXZ
InvoiceID ProductID Qty Price
4 8 1 0 ----> ok
4 9 4 0 ----> ProductID is not existing
4 10 2 0 ----> ProductID is not existing
I think ! This is the problem
|
|
|
|
|
Thanks ... you were right
...i can't believe it was something so small
|
|
|
|
|
Hi;
I am using SQLXML 4.0 for loading bulk load data. I'm having a problem with connectionstring, when I use sqlclient i.e. sqlconnection it gives me error and does not connect to the database. When I use the connection string providing SQLOLEDB provider it works.
private static SqlConnection getConnection()
{
SqlConnectionStringBuilder conStrBuilder = new SqlConnectionStringBuilder();
conStrBuilder.DataSource = "abc";
conStrBuilder.InitialCatalog = "abc";
conStrBuilder.UserID = "abc";
conStrBuilder.Password = "abc";
return new SqlConnection(conStrBuilder.ConnectionString);
}
private void ExecuteBulkLoad()
{
SqlConnection conn = getConnection();
conn.Open();
SQLXMLBulkLoad4 objXBL = new SQLXMLBulkLoad4();
try
{
objXBL.ConnectionString = conn.ConnectionString; // it does not work
objXBL.BulkLoad = true;
objXBL.ErrorLogFile = @"C:\SQLXML3Books.errlog";
objXBL.KeepIdentity = false;
objXBL.Execute(@"C:\booksmapping.xml", @"C:\Books.xml");
}
catch
{
throw;
}
finally
{
// close of the writer and the stream objects.
objXBL = null;
}
}
But if I use objXBL.ConnectionString = "provider=SQLOLEDB.1;data source=abc;database=abc;uid=abc;pwd=abc";
It worked fine.
Any help?
Thanks
M. Essa Mughal
Toronto, CANADA
|
|
|
|
|
Hi;
I've just started playing with SQLXML 4.0, here is the code which I am using to load the XML into database.
SQLXMLBulkLoad4Class bulkLoad = new SQLXMLBulkLoad4Class();
bulkLoad.ConnectionString = connString;
bulkLoad.BulkLoad = true;
bulkLoad.KeepIdentity = false;
bulkLoad.XMLFragment = true;
bulkLoad.Execute("C:\books.xsd", "C:\books.xml");
My question is that, the mapping file i.e. xsd or booksmapping.xml is compulsory to pass or we can have that information into xml data file? We want to avoid two files to maintain.
Thanks
M. Essa Mughal
Toronto, CANADA
Email: essamughal@yahoo.com
|
|
|
|
|
Hello everyone,
I have been working with VBA code in MS Access 2003. I have a Command button which sends an email and then update the column of a table. Here is what I have...
<br />
DoCmd.SendObject, , acForMatTXT, strWho, , , strSubject, strText, -1<br />
strSQL = "UPDATE [Action Item Table] SET ysnActionAssigned = -1 " & _<br />
"Where [Action Item Number] = " Me.Action_Item_Number & ";"<br />
On Error GoTo Err_Execute<br />
CurrentDB.Execute strSQL<br />
on Error GoTo 0<br />
<br />
Err_Execute:<br />
' Here I display error message in a message box<br />
I am getting an error of "Type mismatch". Can someone tell me what is going wrong.
Thank you.
Bashar Amin
Sr. Software Engineer
|
|
|
|
|
Which line is triggering the Type Mismatch?
|
|
|
|
|
CurrentDB.Execute strSQL
When executing the SQL command.
Bashar Amin
Sr. Software Engineer
|
|
|
|
|
Are you explicitly using Dim to create the variable strSQL as a string?
|
|
|
|
|
Yes.
It is like a local variable in the same function.
Bashar Amin
Sr. Software Engineer
|
|
|
|
|
Try adding a Debug.Print line to output your constructed sql UPDATE statement to the immediate window. You can check to make sure the form values are being incorporated the way you think they are. You can also then copy and paste the actual statement from the immediate window and execute it through the SQL view of an access query. This is a good way to test whether or not there is a problem with the UPDATE statement itself.
|
|
|
|
|
Mike,
Thank you for you valuable suggestion. Debug.print is a good way to troubleshoot software bug. I am still getting the "Type mismatch" error but it is updating the table. So I comment out the error check part for now.
Bashar Amin
Sr. Software Engineer
|
|
|
|