query

alter query in mysql

i want to add a new column noOfTry in a table which already have some columns. the column data will be integer type and default value will be 0. i know i need to use alter query, just asking for the correct format of the query for this case ...

Date Range SQL Query

Schedule_ID---Card No----FromDate----ToDate 4-------------1000058----01-Aug-10---31-Aug-10 5-------------1000058----01-Sep-10---30-Sep-10 6-------------1000058----06-Oct-10---26-Oct-10 7-------------1000099----06-Oct-10---26-Oct-10 What will be the query so i can find that is 08-Oct-10 Exist for 1000058 in table SELECT Schedule_ID ...

DATE_FORMAT() in MySQL query

I'm trying to change this timestamp 2010-08-02 00:28:20 to month/day/year - 08/02/10 ..in the query (I know that doing it in the query is faster). $sql = "SELECT * FROM posts ORDER BY post_date DESC"; I tried using the DATE_FORMAT() in the query many ways but I can't seem to get it right.. Can someone please share how to ...

How can I get the total number of items in a SQL result?

I have the following code: [code] <h2>Listado General de Carreras</h2> <% foreach (var item in Model) { %> <p><span class="titulo"><%=Html.ActionLink(item.Nombre, "Details" , new { id = item.ID }) %></span> <sub> Area: <%: item.Area.Nombre%></sub></p> <% } %> <p> <%: Html.ActionLink("Crear Nueva Carrera", "Create") %...

How do I modify this query in MYSQL?

SELECT title, title REGEXP 'apple' as is_fruit FROM mytable; TO: SELECT title, title REGEXP 'apple' or orange...or grapes...as is_fruit... Basically, how do I do an "OR" for REGEXP? ...

query to ignore first 2 rows

i have a query to fetch 100 rows of events ordered by timestamp. i want to ignore top 2 entries from the result set. The problem is that there is no criteria match (simply to ignore first 2 rows). i am using pager (drupal) which results 10 events per page. If i process it after fetching 10 rows i lost 2 entries (first page contains onl...

How to find queries running on a table in oracle

Hi, I ran a SQL Delete from a SQL Developer session and the delete was running for a long time since there were large number of records. Due to some Not Responding problem with SQL Developer client, i lost my session, as the SQL Developer window got closed. I do not have DBA access rights, i can not query views like v$session, v$sqlare...

SQL Server queries case sensitivity

hi I have this database: abcDEF ABCdef abcdef if I write: select * from MyTbl where A='ABCdef' how to get: ABCdef and how to get: abcDEF ABCdef abcdef Thanks in advance forgot to write - sqlCE ...

How to split compound column like ROW, ARRAY?

I have same problem with this stopped thread. http://www.mail-archive.com/[email protected]/msg28070.html QUERY-1 SELECT r.id, ( SELECT rl.reminder_header, rl.reminder_footer FROM reminder_levels AS rl WHERE rl.lookup = ( SELECT MAX(reminder_level_lookup) ...

Counting Null values in MYSQL

hi, How do i count null values while making cross tab query? I have a table with three colums [id, name, answer] i have following records: ID NAME ANS 1 ABC 1 1 ABC 0 1 ABC NULL 2 XYZ 1 2 XYZ NULL 2 XYZ NULL 2 XYZ 1 2 XYZ 0 1 ABC 0 now i would like to get my result: ID Name NULLCO...

Elegant Advanced Rails Queries

I'm having trouble wrapping my head around more advanced Rails query methods. In this case, I have three tables: Users, Friendships, and Events. I have set it up as follows in the models for each User-> :has_many => :friendships, :has_many => :items Friendship-> :belongs_to => :user Event-> belongs_to => :user Friendships are sim...

How to express "or" in a dictionary queryset in django

I'm filtering a big number of users based on attributes. For example, they can be filtered by minimum gpa. So far I've been doing the following to construct my queryset- ('gpa_gt' just means that the gpa property has to be greater than whatever is the query param) if len(request.GET) != 0: kwargs = {} if request.GE...

ExecuteNonQuery with parameters.

I have to process a file that contains a large number of sql statements. The issue is that the sql statement contain parameters. E.g. the file looks like this declare @var1 as nvarchar; set @var1 = 'value'; insert into table (field1, field2, field3) values ('value1', 'value2', @var1); repeates with the next set of three lines. I ...

Finding overlapping dates

I have a set of Meeting rooms and meetings in that having start date and end Date. A set of meeting rooms belong to a building. The meeting details are kept in MeetingDetail table having a startDate and endDate. Now I want to fire a report between two time period say reportStartDate and reportEndDate, which finds me the time slots in wh...

MySQL query results are not a resource

I am having trouble with the query in this code. The problem is one I have had before, the $num = mysql_num_rows($result); part gives me a MySQL error saying it expected a resource. Usually when I have this error it is because I misplaced a single quote some where, but after looking I cannot find any problem, though this query is a bit...

How to show row numbers in PostgreSQL query?

I'd like to show the observation number for each record returned by a PostgreSQL query. I think in 8.4 windowing functions can perform this capability. Edit: I think I just found the answer, but since this hasn't been asked before, I'll keep the question open. I also welcome non-windowing function possibilities. Edit 2: So a little t...

Is it possible to query the system databases in SQL server without using the names?

When doing a query over several databases in SQL server (2005+) I find it sometimes necesary to exclude the system database (master, model, tempdb, msdb and distribution) Is there any OTHER way to filter these besides where name not in (''master', 'model', 'tempdb', 'msdb', 'distribution') I've looked at sys.databases and master.dbo...

Get mysql tables in a query

There is any way to get the tables I'm using in a query? The first method I was using was with regular expressions: // result[1] = "SELECT" // result[3] = "All between FROM and WHERE, ex: `users`, ex: `users`, `test` if($result[1] == "SELECT" && !preg_match('/FROM\s*(.*?,.*?)\s*WHERE/i', $query, $res)) { $tables = preg_replace('/`...

frustrating query - news feed like facebook

im trying to have news feed like facebook. Database Dump http://www.2shared.com/document/RXQ13S-n/exported.html i have feed table, which gets feed for text, image or video. i want to group the latest video and images feed and show them as one row and if someone feed comes after it, then group gets break for that row. the following que...

JQueryUI- Can options take more than one parameter?

I'm trying to make my draggables snap to each other as well as their containing div. Is this possible? this works: $($element).draggable({ snap: true }) but this (and variations of it) will not: $($element).draggable({ snap: true, '#mainwindow' }) Anyone know how to give op...