mysql

What is the best way record monthly user uploads to our web application?

Our web application allows users to upload photos, it uses a PHP script on a LAMP server running on Amazon EC2 to handle image uploads, Amazon S3 to store the files and a MySQL database for recording data about the image (user id, filename, tags etc). I intend to have an image_uploads table in the database with a colum for each month an...

Creating an array from a MySQL table

I'm trying to create an array to use for a curl_multi_exec, but I can't seem to create the array properly. Here is my code: $SQL = mysql_query("SELECT url FROM urls") or die(mysql_error()); //Query the shell table while($resultSet = mysql_fetch_array($SQL)){ ...

Fetch last item in a category that fits specific criteria

Let's assume I have a database with two tables: categories and articles. Every article belongs to a category. Now, let's assume I want to fetch the latest article of each category that fits a specific criteria (read: the article does). If it weren't for that extra criteria, I could just add a column called last_article_id or something s...

Output problem in mysql query in MFC program

I'm currently working on a small MFC program that outputs data from a mysql database. I can get output when i'm using an sql statement that does not contain any variable eg. select album from Artists; but when i try to use a variable the program compiles but i get no output eg. mysql_perform_query(conn,select album from Artists w...

Whats better- query with long 'where in' condition or many small queries?

Maybe it's a little dumb, but i'm just not sure what is better. If i have to check more than 10k rows in db for existanse, what i'd do? #1 - one query select id from table1 where name in (smth1,smth2...{till 30k}) #2 - many queries select id from table1 where name=smth1 Though, perfomance is not the goal, i don't want to go down w...

mysql LOAD DATA INFILE

I am trying to load a data file into mysql table using "LOAD DATA LOCAL INFILE 'filename' INTO TABLE 'tablename'". The problem is the source data file contains data of every fields but the primary key is missing ('id' column). I add a unique id field while I create the database but now I need to import the data into the table starting f...

Select random row from MySQL (with probability)

I have a MySQL table that has a row called cur_odds which is a percent number with the percent probability that that row will get selected. How do I make a query that will actually select the rows in approximately that frequency when you run through 100 queries for example? I tried the following, but a row that has a probability of 0.3...

Maximum number of records in a MySQL database table

What is the upper limit of records for MySQL database table. I'm wondering about autoincrement field. What would happen if I add milions of records? How to handle this kind of situations? Thx! ...

MySQL National Stock Numbers (NSN) for identification of assets

In MySQL are there any restrictions (and/or) practical reasons against using a numbering system similiar to the National Stock Number format as follows 3728-01-234-5678 (this format includes the use of the hyphen between groups of characters within the structure) Would this require the use of a specific engine like InnoDB A newbie stu...

Get data between two date on MySQL

Hello, How can I get the values between two dates. I want to get the values between 2010-01-02 and 2010-01-04. Example: Value DateTime A 2010-01-01 14:55:12 B 2010-01-02 14:55:12 C 2010-01-03 14:55:12 D 2010-01-04 14:55:12 E 2010-01-05 14:55:12 Thanks! ...

Accessing Mysql with JQuery without using php

Hi, I'm very new to JQuery, but I was told the one of the cool things about it is you can query a mysql database right from an html page(or in my case a smarty template)with out needing php. I have not found any examples of this so I am asking if someone has one? Thanks ...

Radius of multiple latitude/longitude points

I have a program that takes as input an array of lat/long points. I need to perform a check on that array to ensure that all of the points are within a certain radius. So, for example, the maximum radius I will allow is 100 miles. Given an array of lat/long (coming from a MySQL database, could be 10 points could be 10000) I need to fi...

MySQL Join a Table if Exists Question

I have a DB which has a table called config. This table could possibly have a config_cstm table that is related by the id to the config table. I was wondering - is there a way to dynamically check for the existence of this table in one simple select statement? In other words, something like: select * from config (IF EXISTS config_...

MySQL full text search with partial words

MySQL Full Text searching appears to be great and the best way to search in SQL. However, I seem to be stuck on the fact that it won't search partial words. For instance if I have an article titled "MySQL Tutorial" and search for "MySQL", it won't find it. Having done some searching I found various references to support for this coming ...

How to use mySql DB from C# on shared hosting?

Hi, i bought a web domain with some web space. They support only mySQL DB, how do i access the my SQL DB on my asp.net application? is there is way to access it through .net base classes without installing third party drivers? ...

Dynamically change MYSQL query within a PHP file using jQuery .post?

Hi, Been trying this for quite a while now and I need help. Basically I have a PHP file that queries database and I want to change the query based on a logged in users name. What happens on my site is that a user logs on with Twitter Oauth and I can display their details (twitter username etc.). I have a database which the user has add...

SQL Group by - Listing all rows by group?

Given data such as Type Value A This A is B Will A a B this A test B work I would like to end up with Type Value A This is a test B Will this work Is this possible? Thanks! ...

How can I optimize the import of this dataset in mysql?

I've got the following table schema: CREATE TABLE `alexa` ( `id` int(10) unsigned NOT NULL, `rank` int(10) unsigned NOT NULL, `domain` varchar(63) NOT NULL, `domainStatus` varchar(6) DEFAULT NULL, PRIMARY KEY (`rank`), KEY `domain` (`domain`), KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 It takes several minute...

MySQL Join Question

Hi i'm struggling to write a particular MySQL Join Query. I have a table containing product data, each product can belong to multiple categories. This m:m relationship is satisfied using a link table. For this particular query I wish to retrieve all products belonging to a given category, but with each product record, I also want to re...

How to query the columns of a table when INFORMATION_SCHEMA gives acces denied?

hi what i am trying to do is get all the collums of a table (the table can be empty) example of what i did before: SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'aTable' AND table_schema = 'theDatabase' it works perfectly on localhost however on my provider it gives: #1142 - SELECT command denied to user ...