mysql

Restricting results of a many to many joined query

I have three tables like this (simplified version): Object --------------- ID | ObjectName --------------- Category ----------------- ID | CategoryCode ----------------- ObjectCategory --------------------- ObjectID | CategoryID --------------------- How can I select ObjectName and CategoryCode for all objects who don't belong to ce...

What's the decimal separator in a MySql INT field?

Is this set somehow in a variable? Is it possible to store decimal values in INT fields or does it have to be FLOAT? Comma or point as a separator? Or does it even matter? Thanks ...

SQL: Counting number of matching results when using a LIMIT query

Say the users table in my MySQL DB contains a very large number of entries. I need to go through all the users, but I want to do it only chunks at a time (i.e. using LIMIT and OFFSET): SELECT * FROM users LIMIT 100 OFFSET 200 Is it possible to know the total number of users matched in the query, but only return a LIMIT number of them ...

How to get values for every day in a month.

Data: values date 14 1.1.2010 20 1.1.2010 10 2.1.2010 7 4.1.2010 ... sample query about january 2010 should get 31 rows. One for every day. And values vould be added. Right now I could do this with 31 queries but I would like this to work with one. Is it possible? results: 1. 34 2. 10 3. 0 4. 7 ... ...

selecting some records from table containing 200 million records

Hello. I am new to sql so my terminologies might not be very correct. I have a table Alignment which has got 250 million records. It has two columns chain_id1 and chain_id2. Some of these chains are foreign keys for chain_id from another table Centroid which has 22000 records. Basically I need all those records which are have both cha...

installing mysqldb for django (jython)?

I installed jython, django on my windows system. I successfully created a project mysite. Now after updating settings in settings.py. i ran 'manage.py' and got the error- Import error - "no module named mysqldb". now, i downloaded mysqldb (which is for python, but i thought it will work for jython also) and i tried to install it. but now...

How to add a seperator between menu items in PHP but not on the end

I'm trying to put an image as a separator between menu items but not on the outside and I'm not sure how to do this.. So it would end up being something like this: HOME | ABOUT | CONTACT unfortunately my code puts one after every entry including the last one. mysql_select_db($database_db_connection, $db_connection); $query_rsMenu = "S...

High Frequency Ajax and MySQL Sleep Overload

I am currently working on a light php framework to use with some high request ajax for my site, and have run into an interesting problem that has me completely stumped. The ajax is for a series of notifications, so the javascript sends off an ajax request for new information every 30 seconds. This ajax is active on every page of the enti...

mysql server in another timezone, needs correct time

A client of mine in Florida has a site hosted on a server in Houston, TX. He is upset that all of his reports are coming out from the database a hour off. to insert records into the database, the MySQL Function time() is used, then a standard SELECT statements get the records out of the database. Is there some easy way I can modify the...

MySQL set NULL Query not always works

UPDATE `table` SET `sent`='1', `taken`='1', `free`=NULL WHERE `owner`='1' AND ISNULL(`sent`) AND !ISNULL(`free`); Works, but set free to NULL not always works. Any ideas? Thx ...

How to cast to string the result of an inner query?

I have the following query (which should return a scalar/numeric), But I still get a sql error. I am using mysql 5.0.77 or 5.1.37 SELECT CAST(SELECT COUNT(*) FROM t1 AS VARCHAR) ...

Data Access Application Framework for .NET + SQL Server?

We are looking to create an in-house Project Dashboard application. Project Managers will use this to create and update projects, submit project status, enter project metrics, etc. A separate reporting piece would read the data entered by the tool and bubble up reporting data. If this were 1990 and the app was to run in DOS I would ch...

Reset SQL variable inside SELECT statement

I am trying to number some rows on a bridge table with a single UPDATE/SELECT statement using a counter variable @row. For example: UPDATE teamrank JOIN (SELECT @row := @row + 1 AS position, name FROM members) USING(teamID, memberID) SET rank = position Is something like this possible or do I need to create a cursor? If it hel...

An online free-trial anti-abuse system design.

I am currently selling time based access passes to an online service at micro payment prices. After payment the customer gets a set of credentials that is only valid for the purchased period. When the access pass expires the customer has to buy a new set of credentials. So basically the credentials are one-time(period) use only. I wo...

different line break characters in CSVs

I use LOAD DATA LOCAL INFILE to upload csv files to MySQL. If the csv was created by a mac, I include LINES TERMINATED BY '\r' in the query. If the csv was created by a MS Office, I include LINES TERMINATED BY '\n' in the query. If the csv was created in Open Office, I omit LINES TERMINATED BY altogether. Is there a way I can formula...

Why the \G in SELECT * FROM table_name\G?

Terminating a MySQL query with \G instead of ; will cause MySQL to return the result set in vertical format, which is sometimes easier to read if the number of returned columns is large. Example: mysql> SELECT * FROM help_keyword LIMIT 3\G *************************** 1. row *************************** help_keyword_id: 0 name...

Seeking elegant way to remove any instances of 544 words from a string

I need to remove any instances of 544 full-text stopwords from a user-entered search string, then format it to run a partial match full-text search in boolean mode. input: "new york city", output: "+york* +city*" ("new" is a stopword). I have an ugly solution that works: explode the search string into an array of words, look up each w...

Selecting max of a sum of two columns

I have a table comparisons. If I run SELECT comparisonID,stu1Vers,stu2Vers,stu1,stu2 from comparisons WHERE stu1!=stu2 and assignmentid=9; I get something like: +--------------+----------+----------+------+------+ | comparisonID | stu1Vers | stu2Vers | stu1 | stu2 | +--------------+----------+----------+------+------+ | ...

Cannot find table details in mysql information_schema

Hi, I am working on an assignment where I am supposed to find all of the tables in information_schema of a "blank" database. I can do this in either MySQL or PostgreSQL. I chose MySQL. So, I have identified all of the tables: CHARACTER_SETS COLLATIONS COLLATION_CHARACTER_SET_APPLICABILITY COLUMNS COLUMN_PRIVILEGES INDEX_STATISTICS KEY...

PHP - problem with nested mysql_fetch_array() driving me crazy

The MySQL query: SELECT title,alias,parent FROM '._prefix.'categories WHERE (language = \''._language.'\' || language = \'all\') && status = \'published\' ORDER BY rank ASC The Result (from phpMyAdmin): title | alias | parent Home | home | 0 Todo | todo | 0 Multiuser| todo_mu | 21 Modulsys | todo_mo...