I'm writing sql to search a database by a number of parameters. How would I go about ordering the result set by the items that match the most parameters in the where clause. For example:
SELECT *
FROM users
WHERE username = 'eitan'
OR email = '[email protected]'
OR company = 'eitan'
Username | email | company
1)...
I want to delete all the records where field name class="10010" from Table A and AentryId = BentryId from Table B.
if i delete the entryId 12 which matches className=10010 from Table A and the same time that same id should delete from Table B also.
Table A:
AentryId className
12 10010
13 10011
14 10010
15 100...
This is a situation I'm generally facing while writing SQL queries. I think that writing the whole column (e.g. long case expressions, sum functions with long parameters) instead of aliases in GROUP BY expressions makes the query longer and less readable. Why doesn't Oracle SQL allow us to use the column aliases in GROUP BY clause? There...
I'm in a situation where I want to add the equivalent of the sql statement
SET QUERY_GOVERNOR_COST_LIMIT
to my query I created with linq to entities.
How would I go about that?
...
I'm using rails 3.0 and MySql 5.1
I have these three models:
Question, Tag and QuestionTag.
Tag has a column called name.
Question has many Tags through QuestionTags and vice versa.
Suppose I have n tag names. How do I find only the questions that have all n tags, identified by tag name.
And how do I do it in a single query.
(I...
Problem:
A Database collumn has a Tristate (0,1,2).
Each of the values are used serversidely.
The Clientcode (which cant be changed anymore) is only able to understand '0,1'.
In the Clients view '1' is identic with '2'. So I want to change the SQL Query in the Database to return '1', if the specific value is > 0.
My current Solution ...
I have a table with three filled columns named "Name", "City" and "Occupation".
I want to create a new column in the same table that contains the number of people who have the same occupation.
"Name" | "City" | "Occupation"
------------------------------
Amy | Berlin | Plumber
Bob | Berlin | Plumber
Carol | Berlin | Lawyer
David ...
Hi,
I want to select the records from a table which are updated or added in the last one month (table doesn’t have any datetime field and I can’t change the table structure).
Is it possible to write a sql query for that? how to fetch those records from table.
regards,
kumar
...
Hello all, I'm very VERY new at this whole web thing. And I'm just very confused in general. Basically, what I want to do is take an input via text using HTML and adding that input to database, table trans. Should be simple but I am lost.
<li>Transaction Number</li>
<li><input type=|text| name=|tnumber| </li> // do i need to use...
I have a staging table (stage_enrolments) and a production table (enrolments). The staging table isn't partitioned, the production table is. I'm trying to use the ALTER TABLE SWITCH statement to transfer the records in the staging table to production.
ALTER TABLE dbo.stage_enrolments
SWITCH TO dbo.enrolments PARTITION @partition_num;
...
I'm writing a tool to gather customer configuration information. One of the questions I want to answer, what OS is the customer database running on.
I haven't found a generic way to find the OS with SQL and I can't create stored procedures on the customer's database.
If there is a way, it's probably vendor specific.
Suggestions? Thank...
Hi all
For one of my recent projects, I had to implement field change tracking. So anytime the user changed a value of a field, the change was recorded in order to allow full auditing of changes.
In the database, I implemented this as a single table 'FieldChanges' with the following fields: TableName, FieldName, RecordId, DateOfChange,...
To make story short, i'm building self-learning banner management system. Users will be able to insert these banners to their site when banners will be shown based on sales/impressions ratio.
I have 4 tables
Banners
bannerID int
bannerImage varchar....
SmartBanners
smartBannerID int
smartBannerArrayID int
bannerID ...
I am not good at jsp but I wondered what can cause such a problem when every other strings are displayed well:
a JSP file queries information of people by their name at Contact (MS Exchange). the query returns the full info of the person; and the first, last names are printed. Last names with apostrophes (Ex: O'reilly) aren't displayed ...
Hi all,
is there a function in SQL Server 2005 that returns NULL [or a boolean value] if any of the arguments (of any type) is NULL, which would save me from writing IF a IS NULL OR b IS NULL OR c IS NULL ....
...
I have some VB.net code that inserts data into my SQL database using a typed dataset as follows:
dim usersTa As New authorizedUsersTableAdapters.Authorized_UsersTableAdapter
usersTa.Connection = New Data.SqlClient.SqlConnection(MY_CONNECTION_STRING)
usersTa.Insert(first_name, last_name)
In the database, there is a primary key b...
I keep finding myself in this situtation:
I have an ASP.NEt 2.0 app. I have to insert into 2 tables in SQL. There is a dependency between the tables. I insert a record the first using a transaction. Then I move onto the 2nd table. But, because the first isn't committed yet the second one throws a error.
...
I have two DBs. The 1st db has CallsRecords table and 2nd db has Contacts table, both are on SQL Server 2005.
Below is the sample of two tables.
Contact table has 1,50,000 records
CallsRecords has 75,000 records
Indexes on CallsRecords:
CallFrom
CallTo
PickUP
Indexes on Contacts:
PhoneNumber
I am using this query to find matches ...
Hello Experts,
I have a flat text file data which I import into a SQL Server table.
It creates and table with specified name along with multiple columns as per data file.
Now I need a query which will return the data and its count. e.g.
data file :
BREAD,MILK
BREAD,DIAPER,BEER,EGGS
MILK,DIAPER,BEER,COKE
BREAD,MILK,DIAPER,BEER
BREAD,...
Is there any kind of performance hit when querying by placing tables in different schemas in SQL Server.
For instance if I had 2 tables, Table1 and Table2, and put Table1 into the test schema and Table2 into the history schema, and then I tried to link the tables in a query, is this implicity slower than having the 2 tables in the same ...