I'm making an update to our datbase and would like to update rows that do not have existing items in another table. I can join the tables together, but am having trouble grouping the table to get a count of the number of rows
UPDATE dpt
SET dpt.active = 0
FROM DEPARTMENT dpt
LEFT JOIN DOCUMENTS doc on dpt.ID = doc.DepartmentID
GROUP ...
I have the following SQL to format a US address into each line for a mailing address but it is rather ugly. Is there a better way to solve this problem or does it have to be this ugly? Also, the problem with this code is that it always ends up with an extra new line at the end.
declare @NL varchar(2);
set @NL = char(13) + char(10);
sel...
Including DISTINCT to an SQL query that also uses ORDER BY CAST(thecolumn AS int) as shown here seems to remove that sorting functionality.
Any reason these cant work together?
(Using sqlite with the C api)
Thanks.
EDIT:
Started with -
sprintf(sql, "SELECT DISTINCT rowX FROM TableX Order By Cast(rowX As int) LIMIT 150 OFFSET %s;", Of...
When using this code (simplified for asking):
var rows1 = (from t1 in db.TABLE1
where (t1.COLUMN_A == 1)
select new { t1.COLUMN_B, t1.COLUMN_C });
var rows2 = (from t2 in db.TABLE2
where (rows1.Contains(t2.COLUMN_A))
select t2;
I got the following error:
The type arguments for method
'System.Linq.Enumerable.Cont...
I'm using Report Builder 2.0 to construct a report that contains datetime data stored in the database as UTC time. Is there a way to convert the UTC time to local time of the computer viewing the report?
Thanks.
...
Having a table with 60 columns, and 200 rows. Altering a BIT column from NULL to NOT NULL, now has a running execution time of over 3 hours. Why is this taking so long?
This is the query that I'm execution:
ALTER TABLE tbl
ALTER COLUMN col BIT NOT NULL
Is there a faster way to do it, besides creating a new column, updating it with va...
I know in an actual query, you can use auto_increment=1 but how is this set with phpMyAdmin?
Is it even possible?
...
I have
Table: ARTICLES
ID | CONTENT
---------------
1 | the quick
2 | brown fox
3 | jumps over
4 | the lazy
Table: WRITERS
ID | NAME
----------
1 | paul
2 | mike
3 | andy
Table: ARTICLES_TO_WRITERS
ARTICLE_ID | WRITER_ID
-----------------------
1 | 1
2 | 2
3 | 3
To summarize, article 4 has no w...
Hey stackers,
I’ve been grinding my head on this for a while… My goal is to return all dates that fall between a start and end date and have a certain period as a factor, from the start date. (hard to explain)
For example…
Start Date: Nov 20, 1987; End Date: Jan 01, 1988; Period: 10 days;
I want these dates: Nov 20, 1987; Nov 30, 19...
I have this query:
select acc_num
from (select distinct ac_outer.acc_num, ac_outer.owner
from ac_tab ac_outer
where (ac_outer.owner = '1234567')
and ac_outer.owner = (select sq.owner
from (select a1.owner
from ac_tab a1
...
Note: In this question I'm using the term "autocomplete" (or "iterative search") to refer to returning search-as-you-type results, e.g. like Google Search gives you. Also my question is not specific to web applications vs. fat client apps.
How are SQL SELECT queries normally constructed to provide decent performance for this type of...
I have a table with a column 'A'.
Some rows have 14 digits for the column 'A' and some have only 12. I need to transform all the entries to 14 digits. The datatype is varchar
I would like to update all the rows at once (one query), adding zeros before the first digit, so an entry like 012345678910 would become 00012345678910.
Is it po...
Hello
I have this query:
SELECT *
FROM sample
INNER JOIN test ON sample.sample_number = test.sample_number
INNER JOIN result ON test.test_number = result.test_number
WHERE sampled_date BETWEEN '2010-03-17 09:00' AND '2010-03-17 12:00'
the biggest table here is RESULT, contains 11.1M records. The left 2 tables about 1M.
this...
Is is possible to accomplish the equivalent of a LEFT JOIN with subselect where multiple columns are required.
Here's what I mean.
SELECT m.*, (SELECT * FROM model WHERE id = m.id LIMIT 1) AS models FROM make m
As it stands now doing this gives me a 'Operand should contain 1 column(s)' error.
Yes I know this is possible with LEFT JOI...
Ok, this may be confusing so I hope I explain it correctly.
I have 4 tables:
business
photos
video
category
I want to display "featured" businesses on the home page (or elsewhere) and I want to show a Yes or No in the table row based upon whether or not there are photos or videos for that business.
Example: Joes Crab Shack has no vid...
I currently have a problem attepting to update a record within my database. I have a webpage that displays in text boxes a users details, these details are taken from the session upon login. The aim is to update the details when the user overwrites the current text in the text boxes.
I have a function that runs when the user clicks the ...
So I have a simple Apache with MySql I am developing a PHP app. I have Users Table in my DB. I vant to let them store Icons.
My question Is what's the best way of attaching such data as icons (100-250kb's) to DB - Is it beter to store them Inside DB or store them as File and some how attaching links to icons into DB. What's the best way...
I have list of procedures. All procedures are not dependent upon each other. So, I need to do is, to run the independent procedures in parallel. I have 4 procedures that are to be run parallel. When the procedures are run successfully, now I need to go to the next task. These procedures create about 10 tables.
Next task is to execute th...
What do I do, I need to fetch data from 3 tables in mysql, here is my current query. All of the tables contain the IDNO which has 03A45 number. But this query isnt returning any results:
SELECT *
FROM father, mother, parents
WHERE father.IDNO=mother.IDNO=parents.IDNO
AND mother.IDNO='03A45'
AND father.IDNO='03A45'
AND p...
I am using Solaris. I have to log into sql plus and run some queries, which give a huge result set.
I want to copy all that into a file. Is there any command for it in unix or sqlplus ?
...