sql

MySQL: order by and limit gives wrong result

MySQL ver 5.1.26 I'm getting the wrong result with a select that has where, order by and limit clauses. It's only a problem when the order by uses the id column. I saw the MySQL manual for LIMIT Optimization My guess from reading the manual is that there is some problem with the index on the primary key, id. But I don't know where I s...

Using PHP to place database rows into an array?

I was just wondering how i would be able to code perform an SQL query and then place each row into a new array, for example, lets say a table looked like the following: $people= mysql_query("SELECT * FROM friends") Output: | ID | Name | Age | --1----tom----32 --2----dan----22 --3----pat----52 --4----nik----32 --5...

MySQL: Updating entry WITHOUT updating timestamp

I have a timestamp in a mysql table with attribute "ON UPDATE CURRENT_TIMESTAMP". Is there a way to manually disable updating the timestamp on a special occasion? (eg: updating the entry to revise a blog post, but not to re-date it) ...

how to this query in right syntax or right way??

i write this query using t-sql and give me an error (Incorrect syntax near the keyword 'OR') How to write it in correct way ? SELECT SUM(Quantity) FROM Invoices WHERE Invoices.InvoiceDocStatusID = CASE @InventoryType WHEN 1 THEN ((2)OR(1)) ELSE 2 ...

SQL query - choosing 'last updated' record in a group, better db design?

Hi, Let's say I have a MySQL database with 3 tables: table 1: Persons, with 1 column ID (int) table 2: Newsletters, with 1 column ID (int) table 3: Subscriptions, with columns Person_ID (int), Newsletter_ID (int), Subscribed (bool), Updated (Datetime) Subscriptions.Person_ID points to a Person, and Subscription.Newsletter_ID points t...

passing combobox value into sql query MS ACCESS

i have a combobox on a form i want the text of the combobox to be passed into a query. my query is: select..from..where something=[Forms]![Enter Data]![comboCup] the form name is enter data and the combobox name is combocup. should i do: [Forms]![Enter Data]![comboCup]![text] or [Forms]![Enter Data]![comboCup]![value] ?? ...

Python: How to execute a SQL file or command

Hi, I have this Python script: import sys import getopt import timeit import random import os import re import ibm_db import time from string import maketrans runs=5 queries=50 file = open("results.txt", "a") for r in range(5): print "Run %s\n" % r os.system("python reads.py -r1 -pquery1.sql -q50 -sespec") file.write('END...

SQL Join Everything From One Table With One Feild From Another Table?

Is there a way to specify a join on all fields from table A with only one field from table B? Is it necessary to specify each individual field from each table instead of using the all symbol (*) for one of the tables? ...

how to check if a combobox is empty without setfocus?

i need to know if any text has been entered into a combobox if i do: If comboReason1.Value <> "" Then it gives me an error, and if i do: If comboReason1.Value <> Null then this doesn't work. how do i check whether text has been entered into the combobox? ...

NullDisplayText in markup vs ISNULL(field, 0) in SQL?

Which approach is better to use: BoundField.NullDisplayText isn't set. NULL-case is foreseen in SQL query, i.e. SELECT ISNULL(amount, 0) FROM table or BoundField.NullDisplayText is set, e.g. "0.00 %". NULL-case isn't foreseen in SQL query, i.e. SELECT amount FROM table What do you think? ...

SQL: find entries in 1:n relation that don't comply with condition spanning multiple rows

I'm trying to optimize SQL queries in Akonadi and came across the following problem that is apparently not easy to solve with SQL, at least for me: Assume the following table structure (should work in SQLite, PostgreSQL, MySQL): CREATE TABLE a ( a_id INT PRIMARY KEY ); INSERT INTO a (a_id) VALUES (1), (2), (3), (4); CREATE TABLE b ...

Sql Select Query Question. Merge Rows

I have a single MYSQL Question and need help ASAP. Database: ------------------------------------------------------------------- Email | Name | Tag ------------------------------------------------------------------- [email protected] |Test Person | TagOne [email protected] |Test...

Importing Excel to SQLCE

I have a table in excel format (2007 but I can save as anything below that, naturally), and I have an SQL Compact Edition 3.5 SP1 Database table with corresponding columns. I simply want to populate the SQLCE table with the data from the excel file. The data consists of strings and integers only. I tried this utility to no avail, I also...

SQL aggregate query question

Hi, Can anyone help me with a SQL query in Apache Derby SQL to get a "simple" count. Given a table ABC that looks like this... id a b c 1 1 1 1 2 1 1 2 3 2 1 3 4 2 1 1 ** 5 2 1 2 ** ** 6 2 2 1 ** 7 3 1 2 8 3 1 3 9 3 1 1 How can I w...

How to query by recent date and value in SQL?

I have a table with three columns: patient_id obs_date weight_val patient_id stores patient identification #, weight_val stores a weight value, and obs_date stores the date when the weight reading was taken. So, a patient can have many different weight readings at different dates. How do you write a query for: select all patient...

Placing PHP array values into a javascript array?

Is these a way i can loop through a PHP array and have the data outputted into a JavaScript array? For example, the JS script below will not work var mon_Loop = <?php echo $rowCount_Mon ?>; var mon_Events = new Array(); for(i = 0; i < mon_Loop; i++) { mon_Events[i] = <?php $divMon[i] ?> } I Know its because the "i" is not a php...

What is wrong with my SQL syntax here?

I'm trying to create a IT asset database with a web front end. I've gathered some data from forms using POST as well as one variable that had already written to a cookie. This is the first time I have tried to enter the data into the database. Here is the code: <?php //get data $id = $_POST['id']; $company = $_POST['company']; $loca...

is it possible to make an EXE out of an access form?

i would like the user to think he's using a regular winform, but in the backend i want to have access handle the DB stuff. is it possible to just use the access form and have everything else disappear in the background? can we make an exe out of the form? what is MDE? ...

How do I write this MySQL query?

I am working on an Asset DB using a lamp stack. In this example consider the following 5 tables: asset, server, laptop, desktop, software All tables have a primary key of id, which is a unique asset id. Every object has all asset attributes and then depending on type of asset has additional attributes in the corresponding table. If ...

SQL Selects on subsets

I need to check if a row exists in a database; however, I am trying to find the way to do this that offers the best performance. This is best summarised with an example. Let's assume I have the following table: dbo.Person( FirstName varchar(50), LastName varchar(50), Company varchar(50) ) Assume this table has millions of rows, howev...