mysql

Is it possible to do asynchronous / parallel database query in a Django application?

I have web pages that take 10 - 20 database queries in order to get all the required data. Normally after a query is sent out, the Django thread/process is blocked waiting for the results to come back, then it'd resume execution until it reaches the next query. Is there's any way to issue all queries asynchronously so that they can be ...

Restrict content access to logged in users with PHP

I have a LAMP setup and I just want to be able to protect content on the webpage (images,css,videos,etc) so that only logged in users can access it. I realize I can do this easily with .htaccess. However I do not want to use the authentication popup, and I want to be able to use sessions and also be able to logout. I am using php to do...

How to use a mysql query to check if a ad should be enhanced

Hello! I have a problem with emphsizing an advertisement - i need to have to different designs for enhanced and non-enhanced ad's! My table is like this: id int(11) UNIQUE // the unique id of the row adresse text // the adress of an advertisement fremhaevninger int(11) // the number of emphasizings of the ad dato datetime ...

weird bit character display

I am storing x and y as bits in mysql database, upon fetch the record using php fetch_assoc, the display is gobbled. And I can't find a way to test the value to see if it's true or false... I tried using if($val), if($val==true) if($val===true), if $val is false, all 3 tests still returns true. any idea? [x] => � [y] => thanks for the...

MySQL select query not working with limit, offset parameters

I am running MySQL 5.1 on my windows vista installation. The table in question uses MyISAM, has about 10 million rows. It is used to store text messages posted by users on a website. I am trying to run the following query on it, query = "select id, text from messages order by id limit %d offset %d" %(limit, offset) where limit is se...

HOW TO SERACH for string IN two mysql TABLES WITHOUT fulltext indexes

hi i have this query to searching for some string in two tables(download , news) and return column called title from that record. but there is something wrong with the code . its just showing result from second table in the code . and if i change tables place in the code again i'm getting result from second table ! $sql="SELECT downl...

MySQL users privileges

Hi, Is there any permission or grant command on a table which make users not able to delete records (row) that inserted by another user. But allow them to delete or update their own record? Thanks, Stephen ...

function behaving differently in diff environments

Environment 1: Working PHP(5.2.4) MySQL(5.1.30) Environment 2: Not Working PHP(5.2.6) MySQL(4.1.25-log) What is it about this function that makes it work in environment 1, and not in environment 2? No errors, just not returning anything. function GetPrice($type, $level){ $result = mysql_query("SELECT * FROM `types` WHERE id = '$typ...

alternative of TOP keyword in mysql

Hi, I want to know the alternative of the TOP keyword as in mysql. I have read about Top Keyword in SQL. Is there any alternative for that in MYSQL. Or any other method in mysql from which we can get same functionality. Thanks Avinash ...

How to rearrange the following data using php?

i retrieved the following data using sql query from mysql TOTAL COMPUTER DATE GROUP ----------------------------------------------- 48 LAPTOP2 2009-08-19 1 77 LAPTOP2 2009-08-20 1 0 LAPTOP2 2009-08-21 1 15 LAPTOP1 2009-08-19 1 25 MAIN 2009-08-...

How to remove all parrents with no children in SQL?

I have a table that has id, name, level (the depth) and parrent_id, is there any nice way to remove all nodes without any children? (On one level suffices)? I know I can do it in application - load all the nodes on given level and the check if they have children, if not remove, but this whould probably be more effective in SQL and I'm no...

Should I run VACUUM in transaction or after?

I have a mobile application sync process. The transaction does a lot of modification on the database. Since this is done on mobile I need to issue a VACUUM to compact the database. I am wondering when should I issue a VACUUM in the transaction, as final statement or after the transaction? I am currently looking for SQLite, but if i...

MYSQL top N rows from multiple table join

Like, there is top keyword in sql server 2005, how to select top 1 row in mysql if i have join on multiple table & want to retrieve extreme of each ID/column. Limit restricts the no. of row returns so it can't solve my problem. ...

PHP based game - giving each user own database

Is it possible to have a webbased PHP/mySQL game, where each user has his own database with data about his/her account. It's a singleplayer management game where each user will need to have their own database. Or atleast, that's the way I see this. Is this the right solution, and will this work in terms of server bandwidth and such. Y...

performance penalty of strings as primary keys?

Hi all, What would be the performance penalty of using strings as primary keys instead of bigints etc.? String comparison is much more expensive than integer comparison, but on the other hand I can imagine that internally a DBMS will compute hash keys to reduce the penalty. An application that I work on uses strings as primary keys in...

Heterogenous database replication

What's a good off-the-shelf tool that can be used to perform replication between mysql and oracle in both directions? We're currently looking at DBMoto which is super, but I was hoping there was something less expensive. The requirements are: Easy to configure and maintain through a GUI. Table-level replication selection, with configu...

Force InnoDB to recheck foreign keys on a table/tables?

I have a set of InnoDB tables that I periodically need to maintain by removing some rows and inserting others. Several of the tables have foreign key constraints referencing other tables, so this means that the table loading order is important. To insert the new rows without worrying about the order of the tables, I use: SET FOREIGN...

MYSQL merge columns

I'm using MySQL and do a select: SELECT LTRIM(Firstname + ' ' Lastname) AS Fullname FROM Persons My result is 0 for every result. Even if i remove the LTRIM, Using CONCAT is giving the same problem. ...

Difficulty with an SQL query.

Hi, I'm trying to write a query for an online coding event website, but I'm finding it particularly difficult to deal with. I have a table submissions: submissions => subid | uid | pid | subts | status uid = userid pid = problem id subts = timestamp when the submission was submitted status = whether the answer is right or not A us...

storing money amounts in mysql

I want to store 3.50 into a mysql table. I have a float that I store it in, but it stores as 3.5, not 3.50. How can I get it to have the trailing zero? ...