|
i have these data in the database table, Meetings
MeetingID Details Hour Minute
1 Meeting Details1 14 10
2 Meeting Details2 14 15
how can i select all the fields of MeetingID 2?
<br />
SELECT MeetingID, Hour, Minute, Details<br />
FROM Meetings<br />
WHERE (Hour =<br />
(SELECT MAX(Hour) <br />
FROM Meetings)) AND (Minute =<br />
(SELECT MAX(Minute) <br />
FROM Meetings))<br />
but this code doesn't fetch any record
|
|
|
|
|
Of course it doesn't - the row with the max hour might not be the same row as the row with the max minute.
If you stored the meeting time in a single field (of type datetime or smalldatetime) which would be the right solution, this would be easy.
SELECT TOP 1 * FROM Meeting ORDER BY MeetingDateTime DESC
As it is with your table you can just do
SELECT TOP 1 * FROM MEeting Order BY Hour DESC, Minute DESC
|
|
|
|
|
|
whether you search for MeetingID =2 or for which where Meeting time is maximum
I think you want to get the all detail of meeting for which meeting time is highest. use following query
SELECT *<br />
FROM mettings<br />
WHERE (hour*60+minute) =(select max(hour*60+minute) from mettings)
hope this helps
|
|
|
|
|
thank you for helping out
|
|
|
|
|
Rupesh Kumar Swami wrote: SELECT *
FROM mettings
WHERE (hour*60+minute) =(select max(hour*60+minute) from mettings)
Why? Multiply the hour by 60 and add the minutes? If anything the other way round, surely?
|
|
|
|
|
the math is fine, it is calculating minutes since midnight.
On a big table it could be slow...
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
J4amieC wrote: Why? Multiply the hour by 60 and add the minutes?
if there are multiple records, for which Metting time is equal to Highest Metting time, then it display all records.
However your suggestion is better.
|
|
|
|
|
i provide my database to client and all stored procedured are open he can view ,so is there any way to encrypt the stored procudered
i have used with encryption clause it is good but it can be easily decrypted by a software which is freely available on net.
|
|
|
|
|
Why did you give your database-password to the client? If he can't open the damn thing, he can't peek in it
I are troll
|
|
|
|
|
actually we have to take the database back up and then we send it to client wherein client restore the database and make changes in web config of asp.net and uses the application
so is there any way where we can lock the database so that he can not peek in or encrypt the stored procedure
|
|
|
|
|
You can do smart things. Just make some table with sources of your procedures encrypted in some heavy algorithm. Then decode it outside of database (or even inside through some .dll with C# CLR integration) and execute it programmatically. Or you can write stored procedure that will exec your encrypted stored procedure
Wish you luck!
Adrian Pasik
|
|
|
|
|
Hi all,
I am using query something like that
select * from table1 where column1 = 'value1' and column2 = 'value2';
and I have created the index like this
create index index1
on table1(
column2
);
i have used only one column because column2 is usually unique and can only sometimes repeat
Will the query will use the index or do i have to create index with both columns? I am using Oracle database.
Regards
Shajeel
|
|
|
|
|
The program I'm working on has a screen full of project data. The client wants to be able to run a "Google like" text search across all the text/lookup fields to return matching projects. Of course they want to be able to search on phrases also, matching all words, some words, etc.
The data is spread across around 10 tables. My first thought was to use Contains() in some capacity, but the db isn't full-text indexed. I'm not sure it would help if it was.
My remaining options seem to be:
1. Concatenate all the string info for each record into a field. Build up a custom select string with multiple Like searches, one for each word in the phrase to search. Run this with exec. Pretty sure the performance will suck on this one.
or
2. Concatenate all the string info for each record into a field. Select this data into a temp table and use a cursor to delete the non-matches for each word in the phrase to search. Pretty sure the performance will suck on this one also.
Are there any options I'm missing or has anyone got any better ideas?
|
|
|
|
|
thrakazog wrote: 1. Concatenate all the string info for each record into a field. Build up a custom select string with multiple Like searches, one for each word in the phrase to search. Run this with exec. Pretty sure the performance will suck on this one.
Well, it ranges from sucky to extremely sucky, depending on the implementation. I'm hoping to write an article about this topic in the weekend
A fast tip; why not create a shadow-table that holds the same columns, as varchar-types? It's a lot faster than converting everything on the fly, and you can let the server insert a varchar-record with a trigger from the original table.
Good luck
I are troll
|
|
|
|
|
There's a new article (not by me btw), containing a simple search-engine algorithm[^] that could be adapted to work with SQL CE
--edit--
This[^] is the article that you wanted
I are troll
modified on Saturday, March 7, 2009 3:22 PM
|
|
|
|
|
Hi All,
Iam Newbie...
IF EXISTS (SELECT RoomID,DateWhenFilled,DateWhenFree,TimeForHouseKeeping
FROM HouseKeeping)
UPDATE HouseKeeping
SET DateWhenFilled=PresidentialSuite.DateWhenFilled,
DateWhenFree=PresidentialSuite.DateWhenFree,
TimeForHouseKeeping=PresidentialSuite.TimeForHouseKeeping
where (HouseKeeping.RoomID = PresidentialSuite.RoomID
and PresidentialSuite.Available='no')
ELSE
INSERT INTO HouseKeeping (RoomID,DateWhenFilled,DateWhenFree,TimeForHouseKeeping)
select PresidentialSuite.RoomID,PresidentialSuite.DateWhenFilled,PresidentialSuite.DateWhenFree,
PresidentialSuite.TimeForHouseKeeping
from PresidentialSuite
where PresidentialSuite.Available='no';
Structure of both tables are not same.
with this Stored Procedure, Iam getting the error...
Msg 4104, Level 16, State 1, Line 4
The multi-part identifier "PresidentialSuite.RoomID" could not be bound.
Msg 4104, Level 16, State 1, Line 4
The multi-part identifier "PresidentialSuite.Available" could not be bound.
Iam unable to find, what the error is?
Please help
|
|
|
|
|
Are you sure that columns RoomID and Avaliable exists in table PresidentialSuite ?
For more info check this google result[^].
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
thanks for ur reply..
yes, they exist.
and RoomID is primary key.
and if i modify the select statement (i just added braces and no other changes)
select (PresidentialSuite.RoomID,PresidentialSuite.DateWhenFilled,PresidentialSuite.DateWhenFree,PresidentialSuite.TimeForHouseKeeping)
then iam getting this error:
Msg 102, Level 15, State 1, Line 14
Incorrect syntax near ','.
|
|
|
|
|
this T-SQL codeselect (PresidentialSuite.RoomID,PresidentialSuite.DateWhenFilled,PresidentialSuite.DateWhenFree,PresidentialSuite.TimeForHouseKeeping)
is not completed,it must contain from caluse to specify from which table those columns comes.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
yeah, it has from clause and where clause too...
INSERT INTO HouseKeeping (RoomID,DateWhenFilled,DateWhenFree,TimeForHouseKeeping)
select PresidentialSuite.RoomID,PresidentialSuite.DateWhenFilled,PresidentialSuite.DateWhenFree,PresidentialSuite.TimeForHouseKeeping
FROM PresidentialSuite
where PresidentialSuite.Available='no';
|
|
|
|
|
try this
INSERT INTO HouseKeeping <br />
select RoomID,DateWhenFilled,DateWhenFree,TimeForHouseKeeping<br />
FROM PresidentialSuite<br />
where Available='no';
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
its not working
same old error
multipart identifier PresidentialSuite.RoomID cannot be bound.............
|
|
|
|
|

CREATE TABLE [dbo].[HouseKeeping]<br />
(<br />
[RoomID] [int] NULL,<br />
[DateWhenFilled] [varchar](50) NULL,<br />
[DateWhenFree] [varchar](50) NULL,<br />
[TimeForHouseKeeping] [varchar](50) NULL<br />
)<br />
____________________________________________________<br />
<br />
CREATE TABLE [dbo].[PresidentialSuite]<br />
(<br />
[RoomID] [int] NULL,<br />
[DateWhenFilled] [varchar](50) NULL,<br />
[DateWhenFree] [varchar](50) NULL,<br />
[TimeForHouseKeeping] [varchar](50) NULL,<br />
[Avaliable] [varchar](50) NULL<br />
)<br />
_____________________________________________________<br />
<br />
Insert Into PresidentialSuite Values(1,'2009.03.06','2009.03.06','20','yes')<br />
Insert Into PresidentialSuite Values(2,'2009.03.06','2009.03.06','20','no')<br />
Insert Into PresidentialSuite Values(3,'2009.03.06','2009.03.06','20','no')<br />
<br />
INSERT INTO HouseKeeping<br />
SELECT RoomID, DateWhenFilled, DateWhenFree, TimeForHouseKeeping<br />
FROM PresidentialSuite WHERE avaliable='no'<br />
SELECT * FROM HouseKeeping
The last select statement should return you two inserted rows in table HouseKeeping.
Hope this will hel you.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
hi,
i didnot use from clause in the first part and used in the second part.
From clause in set solved my problem
thanks alot
|
|
|
|
|