Hi,
the user in my application can choose freely some fields from the database.
people
+ peopleid
+ peoplename
cars
+ carid
+ carnumber
+ carcolor
pers_car
+ carid
+ peopleid
Lets assume the user is selecting the fields peoplename and carcolor to find out which person likes which colours.
Is it possible to identify the missing per...
Hi
I have a table with this structure
id integer
parent_id integer
order_n integer
info text
Each row could have a parent row (parent_id, null if doesn't have a parent), and an order of insertion (order_n). Every time a row is inserted, the order_n field will be set with the correlative "inside his parent". So, two rows of fir...
hi im having a problem with my code
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
list.Items.Clear()
cmd.CommandText = "SELECT * FROM borrow where (Department LIKE '%" & TextBox2.Text & "%')"
cmd.Connection = con
cmd.CommandType = CommandType.Te...
I want to delete all data from a table that has a date prior to 01/01/2006
I am trying this:
delete from table_a
where to_char(last_update_date,'MM/DD/YYYY') < to_char('01/01/2006', 'MM/DD/YYYY')
But this is not working.
What is the best way to compare date's in sql?
...
I have a php query that runs fairly often like this one:
$query = 'SELECT * FROM work_orders '
.'WHERE '
. "((end_time >= ?"
. "AND start_time <= ?) "
. "OR (start_time <= ? "
. "AND end_time >= ? ) "
. "OR (start_time >= ? "
. "AND end_time <= ? )) ";
And a table defined as:
CREATE TABLE IF NOT ...
So we have a production database that is 32GB on a machine with 16GB of RAM. Thanks to caching this is usually not a problem at all. But whenever I start a pg_dump of the database, queries from the app servers start queueing up, and after a few minutes the queue runs away and our app grinds to a halt.
I'll be the first to acknowledge th...
Has anyone comes across a SQL templating engine which allows one to mix SQL with a dynamic language like Ruby or Python?
I'm looking for something similar to Ruby erb templates. For example, in Ruby on Rails you can have various templates for a view:
customers.html.erb (html + ruby)
customers.js.erb (javascript + ruby)
Though I want s...
I am using SQL Server 2005.
SEE END OF THIS POST REGARDING BAD TABLE DESIGN.
I have two columns. I would like to group by the first column with respect to the order of the second column. Microsofts documentation states that GROUP BY clause does not care about order, how can I enforce this??
Here is my pseudo query:
SELECT col_1,
...
In SQL Server, how many transactions will this produce?
DECLARE @deleted BIGINT
SET @deleted = 100000
WHILE @deleted = 100000
BEGIN
DELETE TOP(100000) FROM MYTABLE WITH (ROWLOCK)
where Col1 = 7048 and COL2 = 39727 and Col3 = 0
SET @deleted = (SELECT @@ROWCOUNT)
END
If I cancel after running this for 10 minutes will it need to roll bac...
Hello,
I was wondering what would be the easiest way to update a column by +1? I will be updating a post count of a category based on when users submits a new post.
Thanks.
...
I've taken over an application that has a SQL backend. There are multiple tables, but the two that I'm concerned about are these:
QAProfile
---------
ProfileID <pk> -int
ProfileName
SecurityGroups -varchar(max)
SecurityGroups
--------------
GroupID <pk> -int
GroupName
My issue is that the the SecurityGroups field is a comma delimit...
As example :
I have this scenario where we receive payments, a singular payment per family, and register those payments with it's amount in the DB.
The thing is that a family can move their loan from bank1 to bank2, only if they have 12 or more sequential payments.
As example if they have registered a payment for
oct, nov, dec, jan, ...
Hey, I'm trying to make an Address book for my site and I was thinking of having two panes. The one on the left to have Contact names, and the one on the right to have the contact details.
I can get the Contact pane loaded up using a while loop to cycle through my query, but then I was thinking that I really had no Idea how to load the ...
I have a table with
*PwdSettings that has a value of -50 (which is say 50 days)
*PwdDate (which is the date last updated)
*ExpDate (which is 0 or 1, if Password is old i need it set to 1)
Im trying to write a query to say "IF PwdDate is < PwdSettings Then SET ExpDate = 1"
Here is what I have tried so far, everything throws an error...
Can anyone find my error in this query? I'm using sql server 2000 and I want to update all entries in the CostEntry table to the corresponding value in the ActiveCostDetails table. The where clause DOES work with a select statement.
UPDATE CostEntry CE
INNER JOIN ActiveCostDetails As AD ON CostEntry.lUniqueID = ActiveCostDetails....
Today I've installed the SQL Server 2008 Management Studio Express. As I know, on the start up there is a login screen where I can choose betweeen the authentication and credentials. Now I have startet SSMSE and I cannot connect to my Server(runs locally). I have tried to use my Windows account and also the "sa" account. Both doesn't wor...
Hi, I just got help with the jQuery portion of this code (thanks David Thomas)
this is my current code so far, I was wondering what else I need so that the results are returned.
<div class="toolbar">
<a href="javascript:void(0);" onclick='$("#addC<?=$_SESSION['user_id'];?>").toggle();'><p id="addC20" style="...
I have large MySQL tables with hundreds of thousands of rows.
I need to write a query on a customers table which gets the count of when customers will be available to contact again.
eg.
SELECT 'This week', COUNT(*) FROM customers
WHERE sales_person_id = 1 AND DATEDIFF(NOW(), available_date) < 7
UNION
SELECT 'Next week', COUNT(*) ...
To preface, I'm aware (as should you!) that using SELECT * in production is bad, but I was maintaining a script written by someone else. And, I'm also aware that this question is low on specifics... But hypothetical scenario.
Let's say I have a script that selects everything from a table of 20 fields. Let's say typical customer informat...
I am trying to write a query in Postgresql that pulls a set of ordered data and filters it by a distinct field. I also need to pull several other fields from the same table row, but they need to be left out of the distinct evaluation. example:
SELECT DISTINCT(user_id) user_id,
created_at
FROM creations
ORDER BY crea...