I am making a quiz system, and when quizmakers insert questions into the Question Bank, I am to check the DB for duplicate / very highly similar questions.
Testing MySQL's MATCH() ... AGAINST(), the highest relevance I get is 30+, when I test against a 100% similar string.
So what exactly is the relevance? To quote the manual:
Rele...
What is the simplest, fastest way to complete the PHP code below such that the output is in a user-friendly format (e.g."October 27, 2006")?
$result = mysql_query("SELECT my_timestamp FROM some_table WHERE id=42", $DB_CONN);
$row = mysql_fetch_array($result);
$formatted_date = ???($row['my_timestamp']);
echo $formatted_date;
...
I have a query:
UPDATE choices SET votes = votes + 1 WHERE choice_id = '$user_choice'
But when I execute it in my script, the votes field is updated twice, so the votes will go from 4 to 6 instead to 5. It doesn't seem that it is getting called twice because I echo out stuff to test this and only get one echo. Is there a way to have it...
If this is possible, please provide a sample query or two so I can see how it would work. Both tables will be in the same database.
Thanks!
...
I have one table
CREATE TABLE GUEST(id int(15) not null auto_increment PRIMARY KEY, GuestName char(25) not null);
CREATE TABLE PAYMENT(id int(15)not null auto_increment Foriegn Key(id) references GUEST(id), BillNr int(15) not null);
what is problem in second command, why it is not working please correct me. it did not create new table...
If I do a Create Table If Not Exists, and a table with the same name exists with fewer rows (or columns), what would happen?
...
I have the following rails migration:
create_table :articles do |t|
t.integer :user_id, :allow_null => false
t.integer :genre_id, :allow_null => false
t.string :url, :limit => 255, :allow_null => false
t.string :title, :limit => 60, :allow_null => false
t.text :summary, :limit => 350, :allow_null => false
t.integer :votes_co...
I have tried the following two statements:
SELECT col FROM db.tbl WHERE col (LIKE 'str1' OR LIKE 'str2') AND col2 = num results in a syntax error
SELECT col FROM db.tbl WHERE page LIKE ('str1' OR 'str2') AND col2 = num results in "Truncated incorrect DOUBLE value: str1" and "Truncated incorrect DOUBLE value: str2" for what looks like e...
I'm working on a personal project doing some finance analysis. It's a totally new field for me, and I'm really having fun with it so far, plus working in the high-level language arena is a great break from my embedded systems daytime work.
I have a MySQL backend on a non-local server with a pile of stock data. My task now is to do some ...
The question is if a database connection should be passed in by reference or by value?
For me I'm specifically questioning a PHP to MySQL connection, but I think it applies to all databases.
I have heard that in PHP when you pass a variable to a function or object, that it is copied in memory and therefore uses twice as much memory imm...
This is similar to this question, but it seems like some of the answers there aren't quite compatible with MySQL (or I'm not doing it right), and I'm having a heck of a time figuring out the changes I need. Apparently my SQL is rustier than I thought it was. I'm also looking to change a column value rather than delete, but I think at lea...
Hi to all
I need help for this problem that i'm trying to solve for a while (i'm new in PHP).
I have a form with several checkboxes which values are pulled from a database.
I managed to display them in the form, assign an appropriate value to each, but cannot insert their values into other database.
Here's the code:
<form id="form1" n...
I am searching for a good book or article which will help me optimize my mysql servers even more. I am using InnoDB and want to make sure the whole db is loaded into RAM but don't know how.
...
Hello
I have a problem, and was hoping I could rely on some of the experience here for advice and a push in the right direction. I have an MS Access file made by propietary software. I only want to take half the columns from this table, and import into new(not yet setup)mysql database.
I have no idea how to do this or what the best way...
I have two tables, one stores the products and quantity we have bought, the other stores the sells. The current stock is therefore the sum of all the quantity columns in the bought table minus the number of rows in the sells table. How can this be expressed in MySQL. Remember that there are many different products.
EDIT:
To make it hard...
I have currently more than 100 connections in Sleep state.
Some connection must stay in Sleep state (and don't close) because it's permanent connection but some others (with a different user name) are from some php script and I want them to timeout very fast.
Is it possible to setup a wait_timeout per user? and if yes, How?
...
Hi,
I am looking for a way to maintain PHP sessions across multiple domains on the same server. I am going to be integrating my sites with a Simple Machines Forum so I will need to use MySQL based sessions. Thanks!
...
I'm using MySQL 5.0.45 on CentOS 5.1.
SELECT DISTINCT(email) FROM newsletter
Returns 217259 rows
SELECT COUNT(DISTINCT(email)) FROM newsletter
Returns 180698 for the count.
SELECT COUNT(*) FROM (SELECT DISTINCT(email) FROM newsletter) AS foo
Returns 180698 for the count.
Shouldn't all 3 queries return the same value?
Here is the ...
I found a posting on the MySQL forums from 2005, but nothing more recent than that. Based on that, it's not possible. But a lot can change in 3-4 years.
What I'm looking for is a way to have an index over a view but have the table that is viewed remain unindexed. Indexing hurts the writing process and this table is written to quite freq...
Right now, I have
SELECT gp_id FROM gp.keywords
WHERE keyword_id = 15
AND (SELECT practice_link FROM gp.practices
WHERE practice_link IS NOT NULL
AND id = gp_id)
This does not provide a syntax error, however for values where it should return row(s), it just returns 0 rows.
What I'm trying to do is get the gp_id from gp...