sql

Active User Tracking, PHP Sessions

Alright, I'm trying to work on a function for active user counting in an AJAX based application. I want to express the below SQL Query in correct syntax but I'm not sure how to write it. The desired SQL Query is below: SELECT count(*) FROM active WHERE timestamp > time() - 1800 AND nick=(a string that doesn't contain [AFK]) Now, ...

Finding the 20 most commented 20 news

Hello All, I need to find a function. the scenario is : I have 2 table. 1. news table 2. news_comment table need to find the most commented 20 news. the news_comment table has the relationship with the news table Thank you ...

Relational databases are not suited for my application - what's the alternative?

Hi, I'm writing a CMS in PHP that allows the user to define different fields (e.g. a Blog page could have fields for Title (string), Content (rich text), Picture (file)). I need the user to be able to add and remove fields dynamically, and the only way I can think of to do it with relational DBs is to serialise all these values and stor...

SQL, combining the result

I am using Access and have this SQL SELECT land.id, land.official_name, vaksiner.vaksiner FROM land INNER JOIN (vaksiner INNER JOIN land_sykdom ON vaksiner.id = land_sykdom.sykdom) ON land.kort = land_sykdom.land ORDER BY land.official_name The SQL gives me a result like this: id official_name vaksiner 1 a ...

oracle search word in string

I want to search a word in string in ORACLE in which string is comma separated. Eg. String is ('MF1,MF2,MF3') and now I want to search whether 'MF' exists in that or not. If I am using instr('MF1,MF2,MF3','MF') it will give wrong result since I want to search Full MF in MF1 or MF2 or MF3. ...

2 Select or 1 Join query ?

I have 2 tables: book ( id, title, age ) ----> 100 milions of rows author ( id, book_id, name, born ) ----> 10 millions of rows Now, supposing I have a generic id of a book. I need to print this page: Title: mybook authors: Tom, Graham, Luis, Clarke, George So... what is the best way to do this ? 1) Simple join like this: Select...

Sql Server high performance insert in two related tables

Sirs, I have the following physical model below, resembling an class table inheritance like the pattern from Fowler (http://martinfowler.com/eaaCatalog/classTableInheritance.html) CREATE TABLE [dbo].[ProductItem] ( [IdProductItem] INT IDENTITY (1, 1) NOT NULL, [IdPointOfSale] INT NOT NULL, [IdDiscountRul...

Check if db connection is closed - php

Db connectivity is handled by an include. I want to run this command: mysql_close($con); Only if we currently have a connection. Something like isset()? Thanks Hamad ...

SQL query not working

hi, I'm trying to create a query in an access database for a C# dataset using the query editor but the created method says there is a problem and isn't created correctly. SELECT Discs.* FROM Discs WHERE (Title=@Title OR @Title IS NULL) AND (Type=@Type OR @Type IS NULL) AND (ContainerID=@ContainerID OR @ContainerID IS NULL) AND NOT (@Tit...

How to repair "order by" after union of 2 selects from 1 tables

I have a dropDownList on my form, where i need to have union of values from 2 colums of table [ost]. Type of this columns is currency. I have russian version of access, default value of curency in "rur" and i need "uah". I need to change format and save "order by". I use this query: (SELECT distinct FORMAT([Sum1] ,'# ##0.00" uah.";-# ...

Creating an appropriate index for a frequently used query in SQL Server

In my application I have two queries which will be quite frequently used. The Where clauses of these queries are the following: WHERE FieldA = @P1 AND (FieldB = @P2 OR FieldC = @P2) and WHERE FieldA = @P1 AND FieldB = @P2 P1 and P2 are parameters entered in the UI or coming from external datasources. FieldA is an int and highly n...

sqlite3 date and interval functions

Hi, I wonder whether sqlite3 supports interval function. The following statement is accepted by PostgreSQL, however sqlite3 failed to parse it; select ... from orders where ... and o_orderdate < date '1995-03-01' + interval '3' month Error: near line 4: near "'1995-03-01'": syntax error Then, I modified the statement a little ...

MySQL - Structure for Permissions to Objects

What would be an ideal structure for users > permissions of objects. I've seen many related posts for general permissions, or what sections a user can access, which consists of a users, userGroups and userGroupRelations or something of that nature. In my system there are many different objects that can get created, and each one has to ...

Implementing a "special" Access database to Expression Web

I have just got an answer to my question about combining the result of a SQL. This was done with "ConcatRelated". Now I want to implement this in Expression Web 3. The SQL's I used in Access: SELECT land.id, land.official_name, vaksiner.vaksiner FROM land INNER JOIN (vaksiner INNER JOIN land_sykdom ON vaksiner.id = land_sykdom.sykdom) ...

How to Insert into remote table using Linked server withint Transaction ?

Hi, My Linked server is setup correctly , I am able to perform below query. INSERT INTO [RemoteServer].[Table] SELECT * FROM [LocalServer].[Table] However when I do the same thing within transaction BEGIN TRAN INSERT INTO [RemoteServer].[Table] SELECT * FROM [LocalServer].[Table] COMMIT TRAN I get Errors like O...

Put indexes on a table with lots of BOOL/TINYINT?

An old mentor once told me to place indexes on most things you use a WHERE clause for. Should I put an index on BOOL/TINYINT's? There is a significant amount of them in the table I am working with, and often results are filtered by anywhere from 1-20 of these boolean conditions. ...

not single-group grouping function while using regr_slope

HI I try to run : select year, regr_slope(sum(sale_count),year) as slope, from products group by year It throws "00937. 00000 - "not a single-group group function"" .When i delete year from select clause problem disapears. Shouldn't I be able to select column with which I'm grouping? Oracle 11.2 sqldeveloper ty for help ! ...

Interview question on stored procedures

What kind of things would you not store in stored procedures? ...

How do I select a column with the latest "datetime" data type?

How do I select a column with the latest "datetime" data type, in Visual Web Developer 2008, ASP.NET 3.5 ? In the config data source dialog my WHERE options are greater than cookie, control, etc... but I would like to select where the datetime is the latest in the table. (Select row from table where datetime is last updated....) Tha...

Cursor position at EOF and BOF

Where is the Position of cursor in recordset.EOF and recordset.BOF. Any explanation or link info is appreciated much. ...