|
Hi,
I have the following tables:
Item (ItemID) and Item_Keyword(ItemID, KeywordID).
ItemID is a primary key in the Item table.
In the Item_Keyword table, both ItemID and KeywordID are foreign keys.
I need to select such ItemID, that has ALL specified keywords.
Thanks in advance for any idea/help
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
There might be a better way, but this will work:
specified keywords='C++','C#','ASP'
the where clause of the outer query will need to have the TotalWords = the number of specified keywords (3 in this case).
select itemid from (select count(*) as TotalWords, itemid
from item_keyword ik inner join keyword k on ik.keywordid = k.keywordid
where k.keyword in(<code>'C++','C#','ASP'</code>)
group by itemid) as tbl
<code>where TotalWords = 3</code>
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Thanks, I cam up with the similar solution.
My concern is, that if there are 3 keywords, say 'Java','C#','ASP' ,
this query will still select it, or wouldn't it?
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Elina Blank wrote: My concern is, that if there are 3 keywords, say 'Java','C#','ASP',
this query will still select it, or wouldn't it?
I don't understand the question. Please clarify.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Sorry, you are absolutely right!
It works, thanks a lot!
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
I have created a win service which executes a long latency SQL Server stored procedure. The service sits on a different server than SQL Server. If the win service server unexpectedly crashed right after I have called the stored procedure, would the stored procedure continue its execution or fail because the connection was lost?
|
|
|
|
|
I'm trying to run the following ODBC command. It's returning 0 when I'm expecting a positive integer. Can anyone see where I'm going wrong?
ok=DBC (PREPARE, db_conn, "SELECT c.QuestionID FROM (SELECT DISTINCT QuestionID FROM Questions WHERE TopicID = ?) AS c LEFT OUTER JOIN (SELECT DISTINCT QuestionID, UserID FROM UserResponses WHERE UserID = ?) AS d ON c.QuestionID = d.QuestionID WHERE d.UserID <> ? OR d.UserID IS NULL ORDER BY c.QuestionID": db_stmt)
I am (fairly) confident that the SQL is correct as it is performing as expected when tested in Visual Web Developer.
Thanks,
Alice
|
|
|
|
|
In my ASP.NET.net site ,I sometimes(but not always) get this error :
Timeout expired.The timeout period elapsed prior to completion of the operation or the server is not responding.
I think its sql server error . Someone tell me how I can solve this problem.
I need urgent help .
|
|
|
|
|
There are a number of options:
1. Increase the timeout. See SqlCommand.CommandTimeout
2. Check the hardware configuration of your SQL Server can handle the loads you are applying to it.
3. Check your code for performance bottlenecks.
|
|
|
|
|
In two of my pages I have 6 roundtrips to sql server.In the other 3.Lets say in the worst case average of 3 roundtrips per page.All queries are simple queries that return records with few fields.and number of records are not more than 30.
Can problem be from my side ???? Is it that hard ?
|
|
|
|
|
devboycpp wrote: In two of my pages I have 6 roundtrips to sql server.In the other 3.Lets say in the worst case average of 3 roundtrips per page.All queries are simple queries that return records with few fields.and number of records are not more than 30.
Can problem be from my side ???? Is it that hard ?
First you need to identify the query that is throwing the timeout exception. Once you've identified the query, you can see if it is possible to optimize the query. If not, you can try setting the SqlCommand CommandTimeout[^] to a longer number of seconds.
|
|
|
|
|
Hi,
I am new to Crystal Report. I am having a problem with crystal reporting. When ever I try to connect the Report with Related data by Dataset, no data appears on Report.
But without related data it shows records on Report.
I am trying to follow the tutorials and Database expert to Generate my report
does any body have any clue?
|
|
|
|
|
The insurance Software is to be developed for a group that is acting as an intermediary for the provision of car rental worldwide.
insurance is a tool used by customer or general public to avail the facility of online car rental service. The system is also used by the executives of call Centre setup by the client to provide services to offline customers. The system shall also assist various agents in the travel industry to provide services to their customers.
Desktop application will be a powerful window based application. It will be implemented using VC# front end and SQL Server back end.
o Functionalities
· It should provide interface to Manage Suppliers, Product, Price, Vehicle, Customers, Agents, and Whitelabeller etc.
· It should be able to Manage Users their roles and permissions.
· It should provide an interface for bookings
· It should integrate with Payment application ( Servebase) for payment authorizations.
· It should be able to generate various reports for Admin, Management and Finance.
o Users : It can be used by
§ Call Centre at Central Office
§ Call Centre at regional office
There are two main components of the business the internet and the inhouse call Centre reservation system.
· Booking Engine : this can be used to make online booking
· Agent Interface : this can be used by registered agent to make bookings and to view their details.
· Admin Interface : this can be used by Admin members of the company to view some of the reports.
|
|
|
|
|
And? This reads like a homework assignment. Do you want us to do your homework for you? Or do you have an actual specific problem.
|
|
|
|
|
I was hoping for the homework-done-for-free thing.
Homework assignment completion fee: $300hr (note:5 hour minimum)
"When I get a little money, I buy books and if any is left, I buy food and clothes." --Erasmus
|
|
|
|
|
I have some tables
AccountTypes (1:m)Accounts (1:m)Transaction
AccountTypes
------------
ATypeID AType
---------------------
01 Expanses
02 Advance to Contractors
.
.
.
10 Banks, Sundry Accounts
Accounts
--------
AType AC AName OpDr OpCr Date
----------------------------------------------------------
01 001 Advertisements 0.0 100.0 20/10/2006
..
.
.
.
Transaction
-----------
VType VNo Date TsDesc AType AC Debit Credit
--------------------------------------------------------------------------------------
CP 101 20/10/2006 paid for newspapers 01 001 100.0 0.0
now I want to see all AType,whether their against transaction are occured or not, their Opening Credit and debit
(OpDr & OpCr) and sum of credit of all transaction against that Atype and Acode (AC).
My query only returns records of those which against some transaction are occured. But I also want to include
Opening Cr and Dr in my Reports for trial Balance.
My Query is this:
SELECT AccountTypes.ATypeID, AccountTypes.AType, Accounts.OpDr + SUM([Transaction].Debit) AS TDr, Accounts.OpCr <br />
<br />
+ SUM([Transaction].Credit) <br />
AS TCr<br />
FROM Accounts INNER JOIN<br />
[Transaction] ON Accounts.ATypeID = [Transaction].ATypeID AND Accounts.AC = [Transaction].AC <br />
<br />
INNER JOIN<br />
AccountTypes ON Accounts.ATypeID = AccountTypes.ATypeID<br />
GROUP BY Accounts.OpDr, Accounts.OpCr, AccountTypes.AType, AccountTypes.ATypeID<br />
I think there is some join Problems, Left join may be work.
but can any one help me.
Thanks
Syed Shahid Hussain
|
|
|
|
|
Hi Syed
You need to use an outer join:
SELECT AccountTypes.ATypeID, AccountTypes.AType, Accounts.OpDr +<br />
SUM([Transaction].Debit) AS TDr, Accounts.OpCr +<br />
SUM([Transaction].Credit) AS TCr<br />
FROM Accounts<br />
LEFT OUTER JOIN [Transaction]<br />
ON Accounts.ATypeID = [Transaction].ATypeID<br />
AND Accounts.AC = [Transaction].AC <br />
INNER JOIN AccountTypes<br />
ON Accounts.ATypeID = AccountTypes.ATypeID<br />
GROUP BY Accounts.OpDr, Accounts.OpCr, AccountTypes.AType, AccountTypes.ATypeID
Inner join only reports results where both of the source tables have matching rows - so you would only see accounts that have one-or-more transactions. Using an outer join means that you can see accounts that have no transaction too.
Hope this helps.
Andy
|
|
|
|
|
Hi,I have a small problem,first we used MySql as a database,The database contain realworld data,suddenly we have need to shift database to Sql Server
Is their any way to avoid refill data manually in SqlServer.
Plz,Help me in Solving the problem
Advanced Thanks,
Srilakshmi
|
|
|
|
|
You can use Enterprise Manager (if you have SQL 2000), or SQL Server Management Studio (if you have SQL 2005) to import your data (tables, columns, records) from MySQL.
The wizard to do import/export data should be simple enough to follow.
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson
"Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin
Edbert
Sydney, Australia
|
|
|
|
|
where can find A ADOConnection CLASS package?
i want a CADOConnection ,CADORecordSet ,CADOCommand CALSS ,THANKS For your help first!
my email :swgzj@sina.com
|
|
|
|
|
swgzj wrote: where can find A ADOConnection CLASS
A set of ADO classes - version 2.20
[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
I've got a fairly simple bit of code which will call a stored proc with the following signature:
dbo.UpdateAssembler (@Id int, @Name char(20), @IsActive bit, @Stamp timestamp) I've created and initialized an SqlCommand object with the appropriate parameters setup, the relevant one in this case "Id" has it's IsNullable property set to true. When I try and execute the command I get the following exception:
Procedure or Function 'UpdateAssembler' expects parameter '@Id', which was not supplied. Hmm , I've set Id in the previous lines of code (which could be an int or null , the stored proc does something different if Id is null ).
Any ideas on what might be causing this exception, note that I have verified the following:
- A parameter by the name of 'Id' does exist in the command's parameters (C# side of things)
- Stored proc does want an Id parameter
- The stored proc works fine if I invoke it through the UI in either VS2005 or the Management Studio.
Sig cops got me...
|
|
|
|
|
Ed.Poore wrote: A parameter by the name of 'Id' does exist in the command's parameters (C# side of things)
Okay... But it is looking for a parameter called @Id . Do you supply that parameter?
You might want to post your code - It sounds like a really simple thing like a typo you just need a second pair of eyes to see.
|
|
|
|
|
Hmm, I seem to remember the last time I did something like this it didn't want the @ in the SqlParameter's name, but I shall check it, then I'll post the code if not successful since it's taking an age for VS to load.
Sig cops got me...
|
|
|
|
|
Ok here's the code (putting the @ in made no difference)
Stored Procedure:
ALTER PROCEDURE dbo.UpdateAssembler (@Id int, @Name char(20), @IsActive bit, @Stamp timestamp) AS
BEGIN
IF EXISTS(SELECT * FROM Assembler WHERE ID = @Id)
IF EXISTS(SELECT * FROM Assembler WHERE (ID = @Id AND Stamp = @Stamp))
UPDATE Assembler
SET Name = @Name,
IsActive = @IsActive
WHERE ID = @Id
ELSE
RAISERROR('Different TimeStamps',10,1)
ELSE
INSERT INTO Assembler
(Name, IsActive)
VALUES (@Name, @IsActive)
END Building the SqlCommand (in a semi-factory like method thingy-ma-bob):
SqlCommand command = new SqlCommand("UpdateAssembler");
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("Id", SqlDbType.Int);
command.Parameters.Add("Stamp", SqlDbType.Timestamp);
command.Parameters["Id"].IsNullable = true;
command.Parameters["Stamp"].IsNullable = true; Executing the command:
updateCommand.Parameters["Id"].Value = item.Id;
updateCommand.Parameters["Stamp"].Value = item.TimeStamp;
updateCommand.ExecuteNonQuery(); Note that certain irrelevant bits have been cut out.
Sig cops got me...
|
|
|
|