query

How to list all table in mysql database

Hi I want to list all tables in my mysql database. I want that each table list with column name and datatype. So how could i do this, any query or something like that. Running on php Thanks Avinash ...

Accessing tables from different .mdb files

I need to show a grid of saved projects (compare "orders") in a datagrid, where the projects are saved in an Access 2000 database with a similar schema as follows: ID Name Country_ID Plant_Type 1 'Test' 1 1 2 'Second' 2 2 Let's call the file "Projects.mdb". This is then showed in the data...

Is it possible to speed up a sum() in MySQL?

I'm doing a "select sum(foo) from bar" query on a MySQL database that's summing up 7.3mm records and taking about 22 seconds per run. Is there a trick to speeding up sums in MySQL? ...

SQL Query for lowest time rows

I have a table with one DateTime column. I want to find the rows with lowest time which their times are more than a variable myTime. How can I do that? What kind of index will increase the performance? ...

SQL Server query to select local maximums

I have this data. I need to get the lowest $ full rows for each person. Amount Date Name $123 Jun 1 Peter $120 Jun 5 Peter $123 Jun 5 Paul $100 Jun 1 Paul $220 Jun 3 Paul The result of the SQl Server query should be: $120 Jun 5 Peter $100 Jun 1 Paul ...

Sum values of a single row?

I have a MySQL query that returns a single row that is a series of 1s and 0s. It's for a progress bar indicator. I have the summing of it in code now, but I tried to sum the values in a query, and realized I couldn't use SUM(), because they're many columns but just one row. Is there a way I can sum this automatically in the query? It's...

album tree deletion

i have following table album_id | sub_album_id | name sdf2342 | 0 | family a2243d | sdf2342 | wife 23ods | sdf2342 | jack 23jskd | 0 | places i want to delete selected album with its all the sub_album and if there is more sub_album then de...

Getting info about running update query

On Sql Server 2008, I have a slow-running update query that has been working for 3 hours. Is there any way to get any statistics (say, how many rows have changed so far or something else) about this execution (of course, while executing) ? So that I can make a decision between canceling query and optimize it or let it finish. Or else, s...

MYSQL like a join but only need the newest row?

I want to do the following but in one query: $query = mysql_query("SELECT name FROM tbl_users WHERE category = '1'"); while($row = mysql_fetch_assoc($query)) { $query2 = mysql_query("SELECT datecreated FROM tbl_comments ORDER BY datecreated DESC LIMIT 1"); $row2 = mysql_fetch_assoc($query2...

MySQL query involving cross join, uniqueness, etc

Thankfully, I haven't had to work with particularly complex SQL queries before. Here's my goal. I have the table hams, which I would like to cross-join with the table eggs - that is, get all ham-egg combinations... to an extent. The eggs table also has an attribute how_cooked, which is defined as ENUM('over-easy','scrambled','poached')...

Models in Yii Framework?

I build a website application using Yii Framework. I want to use model with query like this: SELECT u.id, u.username, u.score, (SELECT COUNT(ownerId) FROM post p WHERE p.ownerId = u.id) AS totalPost FROM users u ORDER BY u.score DESC, totalPost DESC LIMIT 10 Please help me to convert the query into models in Yii Framework ... ...

SQL huge selection of IDs - How to make it faster?

I have an array with a huge amounts of IDs I would like to select out from the DB. The usual approach would be to do select blabla from xxx where yyy IN (ids) OPTION (RECOMPILE). (The option recompile is needed, because SQL server is not intelligent enough to see that putting this query in its query cache is a huge waste of memory) How...

JPA Query Validating if input exist in database

Hi, I want to validate if input exist in database in netbeans IDE protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Transaction1 t = new Transaction1(); //t.setTransactionID(12345); t.setFromAccNo(Integer....

LIttle problem with Flex and sqlite query?

Just a quick question about a small problem I'm having with a flex app I'm creating. Its my first time tying to create an app using a local database and I'm getting an error in my query. private function emptyrow(eventObj:CloseEvent):void { var stmt:SQLStatement = new SQLStatement(); id = datagrid_id....

proper way to delete album and its media and sub album and its media

what would be proper way to delete albums hierarchical data with its media. should i just start looping and find all the sub album id and delete thous and make query to delete all the media belonging to that album id. that will be loads of query execution if data is alot or albums are alot for a user. what your device is on this. my...

MySQL Query Issue - Count Query Uses lot of CPU

Hi, We have a table on mysql to log all visitors of our site. The structure is shown below CREATE TABLE `tblvisitors` ( `visitorURL` longtext, `visitorDatetime` datetime DEFAULT NULL, `visitorIP` varchar(255) DEFAULT NULL, `visitorID` int(10) NOT NULL AUTO_INCREMENT, `visitorUser` varchar(255) DEFAUL...

Passing parameters to JavaScript files

Often I will have a JavaScript file that I want to use which requires certain variables be defined in my web page. So the code is something like this: <script type="text/javascript" src="file.js"></script> <script type="text/javascript"> var obj1 = "somevalue"; </script> But what I want to do is: <script type="text/javascript" ...

Dojo filteringSelect query expression

Hi I'm using the dojo filtering select widget. I'm trying to customize the queryExpr. According to all forums/documentation, there are 4 types of expressions: - ${0} - find exact expression - ${0} - contains - ${0}* - starts with - *${0} - ends with I'm trying to accomplish an auto-completion where any word starts with the typed in...

Remove bias from the monthly totals

In order to remove the bias introduced by the differences in the number of days in the months and years (in case of leap years), from monthly total comparisons of arbitrary quantities and assuming, for example, a table named My_Table with a datetime column named order_date, and an integer one named revenue, I use the following query to g...

Value in db is a hyperlink, and wish to list based on the value of the hyperlink

Hi, I have made my parameter as a hyperlink. Now i want to click the hyperlink and then list of all information of that value in hyperlink. How do i do that? From Account No | To Acc No | Amount | Date So, from account no is value exist from db, and a hyperlink. so i wanna click from accno e.g (123456), and then it will list all tran...