mysql

compiling a c++ program including mysql

I'm new to gcc, and trying to compile a c++ program which includes mysql.h using the command: g++ -o test test.cpp -L/usr/include/mysql -lmysqlclient -I/usr/include/mysql It works without issue, but I was wondering if someone could explain the arguments to me. I don't like using commands I don't understand. Thanks ...

[MySQL/PHP] Avoid using RAND()

So... I have never had a need to do a random SELECT on a MySQL DB until this project I'm working on. After researching it seems the general populous says that using RAND() is a bad idea. I found an article that explains how to do another type of random select. Basically, if I want to select 5 random elements, I should do the following (I...

SQL query to get latest record for all distinct items in a table

I have a table of all sales defined like: mysql> describe saledata; +-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ | SaleDate | datetime | N...

Test my forms for proper query escaping

CodeIgniter claims do sanitize POST variables. I'm also using DataMapper which I believe also does it's own thing. I would like to double check to make sure it's doing what it's supposed to be doing. How can I do this? I'd like to test this without destroying anything, would typing random escaped characters work? What should I see enter...

Querying two tables with one query

I want to get two separate tables by executing one query in MySQL. If you know how, please reply. ...

query mysql table and fetch rows posted in 3 days

Hey guys how can i query my mysql database and fetch rows which are posted in earlier 3 days i know how to fetch todays's rows but not 3 days ago time will save in my table like this : 2010-01-20 19:17:49 and this is what i know : SELECT id FROM pages WHERE date=now() but i need to show posts in 3days and im looking for ...

incrementing a table column's data by one || mySql

iam having a table with columns like id || counter if i do something (some event) i want the counter's value(at a particular id) to increase by one , currently iam doing this : //get current value current_value = select counter from myTable where id='someValue' // increase value current_value++ //update tabl...

How to select a random record from a MySQL database?

I am using the following query to select 1 random record - SELECT name FROM table WHERE id >= (SELECT FLOOR( MAX(id) * RAND()) FROM table ) ORDER BY id LIMIT 1 but it gives me the same set of records every time I call it. How do I get better random record? ...

need help on my query.

i have one table : nobel(yr, subject, winner) and i have this query : In which years was the Physics prize awarded but no Chemistry prize. this is what i tried : select distinct yr from nobel where subject='physics' and subject!='chemistry' but is not working where i am going wrong. see, i am not here to make my homework from someon...

Avoiding Nested Queries

How Important is it to avoid nested queries. I have always learnt to avoid them like a plague. But they are the most natural thing to me. When I am designing a query, the first thing I write is a nested query. Then I convert it to joins, which sometimes takes a lot of time to get right. And rarely gives a big performance improvement (s...

Eliminate subquery for average numeric value

Quest The query selects all the points beginning with "Vancouver" and are within a 5 minute area from the center of all locations beginning with "Vancouver". For example, Vancouver South Fraser, Vancouver Fairview, and Vancouver Ballantree Place W have latitudes and longitudes within 5 minutes of their average latitude and longitude. Th...

Nant: instruct MySql to create db and run scripts

How do I instruct Nant to tell MySql to run ddl scripts from a particular location and then run other scripts as instructed? Google let me to many sites which unfortunately do not work... ...

how to retreive the last updated data from mulitple categories using php and mysql

Hi all, How to retreive the last updated data from mulitple categories using php and mysql. For example: Category Table: id categoryName 1 test1 2 test2 3 test3 Product Table id categoryId productName dateTime 1 1 product1 2010-05-06 10:00:37 2 1 product2 2010-05-06 10:10:41 3 2 product3 ...

MySQL Select distinct values across multiple tables..

I have two tables: table_1 uid | xid | name table_2 uid | elements | time | pkey I want to select multiple rows of xid, elements and time where time is the 10 smallest values and uid (or xid) is distinct. uid, xid in in table_1 is unique and the relationship between uid in table_1 and table_2 is one to many.. I tried something like...

how to write this query using joins?

Hi, i have a table campaign which has details of campaign mails sent. campaign_table: campaign_id campaign_name flag 1 test1 1 2 test2 1 3 test3 0 another table campaign activity which has details of campa...

Best PHP timezone list

I have looked over the PHP list of supported timezones, but the whole list is a little long to include in a drop-down menu, for the user to select his or her timezone. Is there a list with the main city/area on that can be used? My geography is terrible and add that to not knowing all the area and which timezone they fall into it could...

again new query. i am trying to solve this from one hour. please help

Query : List the film title and the leading actor for all of 'Julie Andrews' films. there are three tables movie (id, title, yr, score, votes, director) actor (id, name) casting (movieid, actorid, ord) select movie.title,actor.name as cont from movie join casting on (movie.id=casting.movieid) join actor on (casting.acto...

Using MySQL as data source in Microsoft SQL Server Analysis Services

Hi, I have installed the latest .net connector (http://www.mysql.com/downloads/connector/net/), I can add MySQL databases as Data Sources, I can even browse through the data from Business Intelligence Studio. The problem is that I CANNOT create a datasource view, or if I do create one without tables, trying to add them after the fact gi...

subsonic 2 join on multiple columns

I want to transfer the following statement to SubSonic 2.2 SELECT b.* FROM tableA a INNER JOIN tableB b ON (a.year = b.year AND a.month = b.monath AND a.userid = b.userid); My problem is that SubSonic's SqlQuery.LeftInnerJoin() command has no overload which takes more than one column. Since any join can be rewri...

How to sort MySQL query by two columns

The following is my DB data, how can I sorting it by sid and prev_sid with php/mysql!? sid prev_sid type 000 197 app_home 197 198 page_teach 198 218 page_teach 199 211 page_step 211 207 link 218 559 page_step 559 199 page_step Result: sid prev_sid typ...