mysql

FULLTEXT search(Mysql) is slow for the first time and then from second time onwards it gets much faster.

Hi, I have a table with 4000 records(Which is much easier to handle through full text search). when the search query is executed for the first time it is much slower. It takes about 5 to 10 seconds. Then it gets faster. If the site remains inactive for 10 or 15 minutes, and when I try to execute the query again it gets slower. I am usi...

codeigniter fatal error, trying to read database

Fatal error: Call to a member function result() on a non-object in C:\wamp\www\system\application\models\users_model.php on line 8 <?php class Users_model extends Model { function get_records() { $query = $this->db->get('users'); return $query->result(); } } ?> ...

PHP - Retrieve Data From mySQL Server

Hello, Does anyone know how to retrieve a piece of data and display the results in php file? A similar query that I would enter is something like this: SELECT 'email' FROM 'users' WHERE 'username' = 'bob' Thus, the result would be just the email. Thanks, Kevin ...

Triggers are they asynchronous ?

I have a table A which maintains count of total users in Table B. All I care is that the count in Table A is in sync with the number of users in the table B. So, whenever I insert a user in Table B, I want the count to be incremented/decremented depending on insert of user or delete. There are two ways:- a) In case I am inserting the...

highlighting data values in a sql result set

I can think of a number of ways to do this in PHP or even JavaScript, but I'm wondering if there's a SQL-based technique I'm overlooking. I have a database table, let's say 20 fields X 10 rows. I want to display the entire table on an web page, so I'd do something like SELCT * FROM data_table;, and then format the result set using HTML...

Unserialize data and check it against an id in MySQL

I have a row of IDs in a database that has been serialized. What I'm trying to do is check those serialized IDs against a known ID to see if it should be excluded or not. for example: "SELECT * FROM mydb WHERE id = 4 AND checkID != 'an id in the serialized column' " What's the best way to go about this? ...

General Mysql Database question

I have been having the hardest time for the last couple of months to really grasp mysql. Everytime no matter what the framework, programming language, computers (pc's), I have had no luck. My question is this, is there some functionality in mysql preventing the database crud operations from being run on a different domain name? Could it...

Select nth percentile from MySQL

I have a simple table of data, and I'd like to select the row that's at about the 40th percentile from the query. I can do this right now by first querying to find the number of rows and then running another query that sorts and selects the nth row: select count(*) as `total` from mydata; which may return something like 93, 93*0.4 = ...

MySQL equivalent of PQexecParams?

Does libmysqlclient have an equivalent to libpq's PQexecParams which allows you to send params separately from the query string, making SQL injection impossible and escaping special characters unnecessary? I couldn't find anything except the prepared statement API which seems to be rather complicated/overkill for such a simple thing. Ho...

Compare two table and find matching columns

Hi, I have two tables table1 and table2, i need to write a select query which will list me the columns that exist in both the tables.(mysql) I need to do for different tables (2 at a time) Is this possible? I tried using INFORMATION_SCHEMA.COLUMNS but am not able to get it right. ...

Does Python Django support custom SQL and denormalized databases with no Foreign Key relationships?

I've just started learning Python Django and have a lot of experience building high traffic websites using PHP and MySQL. What worries me so far is Python's overly optimistic approach that you will never need to write custom SQL and that it automatically creates all these Foreign Key relationships in your database. The one thing I've lea...

Inserting Newline from XML to Database

I am trying to parse this xml document in which a newline is required for certain fields and must be inserted into the database with the newline. But I've been running into problems. 1)First Problem: \n Character The first problem I had was using the \n like below. <javascript>jquery_ui.js\nshadowbox_modal.js\nuser_profile.js\ntableso...

MySQL REGEXP: matching blank entries

Hi, I have this SQL condition that is supposed to retrieve all rows that satisfy the given regexp condition: country REGEXP ('^(USA|Italy|France)$') However, I need to add a pattern for retrieving all blank country values. Currently I am using this condition country REGEXP ('^(USA|Italy|France)$') OR country = "" How can achieve ...

Creating a [materialised]view from generic data in Oracle/Mysql

I have a generic datamodel with 3 tables CREATE TABLE Properties ( propertyId int(11) NOT NULL AUTO_INCREMENT, name varchar(80) NOT NULL ) CREATE TABLE Customers ( customerId int(11) NOT NULL AUTO_INCREMENT, customerName varchar(80) NOT NULL ) CREATE TABLE PropertyValues ( propertyId int(11) NOT NULL, customerId int(11) NOT...

How can I get FOUND_ROW()s from an active record object in rails?

When querying the database with: @robots = Robot.all(:condition => [:a => 'b'], :limit => 50, :offset => 0) What is the best way to get the total number of rows without the :limit? In raw MySQL you could do something like this: SELECT SQL_CALC_FOUND_ROWS * FROM robots WHERE a=b LIMIT 0, 50 SELECT FOUND_ROWS(); Is there an active r...

Echoing a pseudo column value after a COUNT

Hi Gang... Please don't beat me if this is elementary. I searched and found disjointed stuff relating to pseudo columns. Nothing spot on about what I need. Anyway... I have a table with some rows. Each record has a unique ID, an ID that relates to another entity and finally a comment that relates to that last entity. So, I want to ...

What frameworks to use to bootstrap my first production scala project ?

I am making my first foray into scala for a production app. The app is currently packaged as a war file. My plan is to create a jar file of the scala compiled artifacts and add that into the lib folder for the war file. My enhancement is a mysql-backed app exposed via Jersey & will be integrated with a 3rd party site via HttpClient inv...

Letting users try your web app before sign-up: sessions or temp db?

I've seen a few instances now where web applications are letting try them out without you having to sign-up (though to save you need to of course). example: try at http://minutedock.com/ I'm wondering about doing this for my own web app and the fundamental question is whether to store their info into sessions or into a temp user table?...

customer.pk_name joining transactions.fk_name vs. customer.pk_id [serial] joining transactions.fk_id [integer]

Pawnshop Application (any RDBMS): one-to-many relationship where each customer (master) can have many transactions (detail). customer( id serial, pk_name char(30), {PATERNAL-NAME MATERNAL-NAME, FIRST-NAME MIDDLE-NAME-INITIAL} [...] ); unique index on id; unique cluster index on pk_name; transaction( fk_name char(30), tran_type char(1...

What's wrong with this SQL UPDATE query?

I wouldn't ask if i wasn't sure that i have 100% no idea why this isn't working, so, in PHP i'm simply trying to update a value in the MySQL database: The field im updating - Name: read - Type: tinyint - Length: 1 Here is the PHP code: do_SQL("UPDATE messages SET read=1 WHERE id='".$id."'"); The do_SQL function is working ...