My table looks like this:
`MyDB`.`Details` (
`id` bigint(20) NOT NULL,
`run_id` int(11) NOT NULL,
`element_name` varchar(255) NOT NULL,
`value` text,
`line_order` int(11) default NULL,
`column_order` int(11) default NULL
);
I have the following SELECT statement in a stored procedure
SELECT
RULE
,TITLE
,SUM(IF(t.PASS...
Hi,
I am trying to find out the maximum value for an integer (signed or unsigned) from a MySQL database. Is there a way to pull back this information from the database itself?
Are there any built-in constants or functions I can use (either standard SQL or MySQL specific).
At http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html it...
Is there a simple way in SQL to convert a string or an array to rows of a table?
For example, let's stay the string is 'a,b,c,d,e,f,g'. I'd prefer an SQL statement that takes that string, splits it at commas and inserts the resulting strings into a table. In PostgreSQL I can use regexp_split_to_array() and split the string into an array...
I'm adding to a combo box an ID and a name that I'm pulling from a database. My problem is that for some reason my loop doesn't end once it reaches the end of the records in the database table. Here's my code:
For intcount = 0 To dtOrders.Rows.Count - 1
cmbSearch.Items.Add(dtOrders.Rows(intcount)("EmployeeID").ToString & " "...
I have a table basically like so
ID | ItemID | Start | End |
---------------------------------------------------------------
1 234 10/20/09 8:34:22 10/20/09 8:35:10
2 274 10/20/09 8:35:30 10/20/09 8:36:27
3 272 10/21/09 12:15:00 10/21/09 12:17:...
This is staight forward I believe:
I have a table with 30,000 rows. When I SELECT DISTINCT 'location' FROM myTable it returns 21,000 rows, about what I'd expect, but it only returns that one column.
What I want is to move those to a new table, but the whole row for each match.
My best guess is something like SELECT * from (SELECT DIS...
Here's my simple query. If I query a record that doesn't exist then I will get nothing returned. I'd prefer that false (0) is returned in that scenario. Looking for the simplist method to account for no records.
SELECT CASE
WHEN S.Id IS NOT NULL AND S.Status = 1 AND (S.WebUserId = @WebUserId OR S.AllowUploads = 1) THEN 1
...
I have a database that acts like a triple store, except that it is just a simple MySQL database.
I want to select all triples that have a common predicate and object. Info about RDF and triples
I can't seem to work out the SQL.
If I had just a single predicate and object to match I would do:
select TRIPLE from TRIPLES where PREDICATE...
I want to query like this:
select * from table where concat(',', ServiceCodes, ',') like '%,33,%';
select * from table where (','||ServiceCodes||',') like '%,33,%';
so, I wrote this code:
ICriteria cri = NHibernateSessionReader.CreateCriteria(typeof(ConfigTemplateList));
cri.Add(Restrictions.Like(Projections.SqlFunction("concat", NH...
I am reading though the sql server 2008 bible and I am covering the views section. But he really dont explain the purpose of views. What is a good use for views. Should I use them in my website and what are the benefits of them.
...
i have two dates
ValidFrom : 20-04-2010
validTo : 02-05-2010
i need to know 4 days(date) before the validity expire .how to calculate the 4 days before date of the validity expire date 02-05-2010
...
Actually if i am doing INNER JOIN of two tables then i will get all matched records from the two tables.
But i want to get all the unmatched rows only.
Is there any way to do that?
Or Any JOIN available for that?
...
I am trying to take database backup. How can I do that when getdate is being appended with file name with format dd/mm/yyyy.
declare @dbName VARCHAR(100)
declare @path VARCHAR(100)
set @dbName='CallMeIndia'
set @path='F:\'+@dbName +'-'+convert(varchar(50),getdate(),103)+'.bak'
BACKUP DATABASE @dbName
TO DISK= @path
...
I have an sql statement that currently is just returning all the end parent rows for a list of child rows:
SELECT DISTINCT row
FROM table heirarchy
WHERE parent_row = NULL
CONNECT BY nocycle PRIOR parent_row = row
START WITH row IN (select statement returning child rows)
Is there a way to show the child and its ...
I have a table which contains house details called property. I am creating a localised application, and I have a db table called propertylocalised. In this table is held duplicates of the data and culture column e.g.
key culture propertyname
1 en helloproperty
1 fr bonjourproperty
At the moment I have all my en...
I created a query that takes a database backup at certain specified location.
I want to use it as a stored procedure but this should act as a global stored procedure so that whenever this SP is called. Then database backup is taken.
It uses DB_Name() to take database backup of owner database.
Is it possible to create any such SP or Fun...
I have a page that shows statistics for users, this cannot be cached because each user has different statistics and there are many thus the real time query must be made.
What the way to avoid database server overload when user will click F5's to refresh or to ask different queries in short time intervals ?
...
Im using a sequel for search like this using PDOs
$states = "'SC','SD'";
$sql = "select * from mytable where states in (:states)";
$params = array(':states'=>$states);
and I use my function
$result = $this->selectArrayAssoc($sql, $params);
where my selectArrayAssoc function as following
public function selectArrayAssoc($sql, $params...
I need to performance tune following SQL query by removing "OR" statements
Please help ...
SELECT a.id, a.fileType, a.uploadTime, a.filename, a.userId, a.CID, ui.username, company.name companyName, a.screenName
FROM TM_transactionLog a, TM_userInfo ui, TM_company company, TM_airlineCompany ac
WHERE
(
a.CID = 3049
)...
This query gives an error:
select ep,
case
when ob is null and b2b_ob is null then 'a'
when ob is not null or b2b_ob is not null then 'b'
else null
end as type,
sum(b2b_d + b2b_t - b2b_i) as sales
from table
where ...
group by ep, type
Error: ORA-00904: "TYPE": invalid identifier
When I run it with group by ep, the...