This is an optimization question, mostly.
I have many forms on my sites that do simple Inserts and Updates. (Nothing complicated)
But, several of the form's input fields are not necessary and may be left empty. (again, nothing complicated)
However, my SQL query will have all columns in the Statement.
My question, is it best to optimi...
I have tracking table tbl_track with id, session_id, created_date fields
I need count unique session_id for one day
here what i got:
select count(0)
from (
select distinct session_id
from tbl_track
where created_date between getdate()-1 and getdate()
group by session_id
)tbl
im feeling that it could be ...
Hi,
as topic says, I don't want to return the first two letters in the return values
just an example:
select companyname from companies
returns companyX
Can I write a query that returns panyX instead?
Thanks in advance
...
hi,
i am using php/mysql.
i have a product table .
in which most product have starting name with number.
i want to listout all products start with any number.
any one have idea about it....
...
I'm using MySQL and I have the following table:
| clicks | int |
| period | date |
I want to be able to generate reports like this, where periods are done in the last 4 weeks:
| period | clicks |
| 1/7 - 7/5 | 1000 |
| 25/6 - 31/7 | .... |
| 18/6 - 24/6 | .... |
| 12/6 - 18/6 | .... |
or in the last 3 months:
...
How can I achieve Outer Apply in LINQ? I'm having a bit of a problem.
Here's the SQL Query I'm using.
SELECT u.masterID
,u.user
,h.created
FROM dbo.Users u
OUTER APPLY (SELECT TOP 1 * FROM UserHistory h where h.masterID = u.masterID ORDER BY created DESC) h
...
how to
compare the values of same table(say for eg: Order table) each and every time the record get inserted ,
if the record with same values get inserted already in same table i should not insert the new record with same values. how to do that exactly in sql server 2008
...
SQL Server 2000. Single table has a list of users that includes a unique user ID and a non-unique user name.
I want to search the table and list out any users that share the same non-unique user name. For example, my table looks like this:
ID User Name Name
== ========= ====
0 parker Peter Parker
1 parker Mary...
The approach i always had in programming a winforms or wpf application to perform queries on a database is the following:
Design an interface with several controls to pass parameters to my query classes
Build a "DataAccess" class with fields, properties and methods for the queries, based on Linq or Entity Framework as data source.
Mana...
self join- how to use the aggregate functions
select a.tablename,
b.TableName,b.UserName from Employee a inner join
Employee b on a.ColumnValue=b.ColumnValue
and and a.TableName <> b.TableName and
a.UserName=b.UserName
and also to check whether the same user has count of records i.e Employee a = count of records of Employee b...
Hi
I have a below SQL query
SELECT `User`.`username` , Permalink.perma_link_id, Permalink.locale,
Permalink.title, DATEDIFF( CURDATE( ) , Permalink.created ) AS dtdiff,
`TargetSegment`.segment_text, TargetSegment.source_segment_id,
TargetSegment.perma_link_id ,TargetSegment.created ,
TargetSegment.updated, DATEDIFF...
I would like to make a query for database user roles for all databases in my sql server instance. I modified a query from sp_helpuser:
select u.name
,case when (r.principal_id is null) then 'public' else r.name end
,l.default_database_name
,u.default_schema_name
,u.principal_id
from sys.database_principa...
i using the dynamic query to pass the variables
select a.TableName, COUNT(a.columnvalue) as '+'count'+' from Settings a
where a.ColumnValue in ('+ @columnvalue +') and a.Value in (' + @value +')
the @columnvalues = 'a','b','c'
@value ='comm(,)','con(:)'
how to pass this in dynamic query
any idea???
...
Hello everyone,
I'm working on "describe table" output to show a list of fields and their types, i want my primary keys to be at top of the list..
I think there's no way to sort describe's results using SQL (something like 'order by') rather than sorting it in PHP.
what do you think guys ?
thanks
...
I have a client with 5000 emails from an old list he has that he wants to promote his services to. He wants to know which emails on the list are still valid. I want to check them for him - without sending out 5K emails randomly and then being listed as a spammer or something. Ideas?
...
I'm having some trouble coming up with a query for what I am trying to do.
I've got a table we'll call 'Movements' with the following columns:
RecID(Key), Element(f-key), Time(datetime), Room(int)
The table is holding a history of Movements for the Elements. One record contains the element the record is for, the time of the recorded l...
I have two tables. Table A has an id column. Table B has an Aid column and a type column. Example data:
A: id
--
1
2
B: Aid | type
----+-----
1 | 1
1 | 1
1 | 3
1 | 1
1 | 4
1 | 5
1 | 4
2 | 2
2 | 4
2 | 3
I want to get all the IDs from table A where there is a c...
Hi,
I have been having trouble searching through a MySQL table, trying to find entries with the character (UTF-16 code 200E) in a particular column.
This particular code doesn't have a glyph, so it doesn't seem to work when I try to paste it into my search term. Is there a way to specify characters as their respective code point inst...
Given the following tables:
Recipes
| id | name
| 1 | 'chocolate cream pie'
| 2 | 'banana cream pie'
| 3 | 'chocolate banana surprise'
Ingredients
| id | name
| 1 | 'banana'
| 2 | 'cream'
| 3 | 'chocolate'
RecipeIngredients
| recipe_id | ingredient_id
| 1 | 2
| 1 | 3
| 2 | 1
| 2 | ...
Following is a dump of the tables and data needed to answer understand the system:-
The system consists of tutors and classes.
The data in the table All_Tag_Relations stores tag relations for each tutor registered and each class created by a tutor. The tag relations are used for searching classes.
CREATE TABLE IF NOT EXISTS `Tags` (
...