I want to store emails into a database and then have them displayed properly in Ruby on Rails to the user (ideally with a nicely formatted, collapsible header, attachment support, etc). Is there already a good way to do this?
Right now, I store the emails to the database as a text, but I am struggling with a good way to display them to...
Hello!
My workmate and I are trainees and we got an exercise to realize a project. We have decided us to create a customer management in Java. Now we have to choose a database. We are able to use Oracle, MySQL, PostgreSQL, HSQLDB and of course other Open Source databases.
So, what database is recommend for us?
I thought Oracle is too com...
I have a table files with files and a table reades with read accesses to these files. In the table reades there is a column file_id where refers to the respective column in files.
Now I would like to list all files which have not been accessed and tried this:
SELECT * FROM files WHERE file_id NOT IN (SELECT file_id FROM reades)
This ...
Hello
I am developing a script in my localhst using PHP and mysql and I am dealing with large data (about 2 millions of records for scintific research)
some queries I need to call once in a life (to analyse the data and prepare some data); however it takes very long time for example: now my script is analysing some data for more than 4...
I have a store procedure that gets a lock, runs a select, does some simple processing and runs an insert. This has worked fine for over a year but today every so often a connection will hold the lock and not release it until the lock times out. So if i use the
select IS_USED_LOCK('up_XML_insertUIAudit_lock');
I can determine what c...
I have a plus/minus system where a user can add one or minus one away from a blog post.
My database (MySQL) table looks like this:
userid
entry id
vote - which is +1 or -1
timeStamp
I have set the timeStamp to default to CURRENT_TIMESTAMP.
I have to methods plus() and minus(). Both do the same thing but one inserts +1 into 'vote' and...
I have a SQL table readings something like:
id int
client_id int
device_id int
unique index(client_id, device_id)
I do not understand why the following query is so slow:
SELECT client_id FROM `readings` WHERE device_id = 10 ORDER BY client_id DESC LIMIT 1
My understanding with the index is that mysql keeps an ordered list (one prop...
I want to check for the username in the users table. If it's found, then I want to get the id. Otherwise, I want to insert the username as a new record, then get the id.
Here's my code:
<?PHP
$sql = "SELECT id FROM users where username = '$username'";
$query = mysql_query($sql) or die(mysql_error());
$result = mysql_num_rows($query);
if...
This is my table structure:
The error message is:
#1066 - Not unique table/alias: 'user'
The following is my code.
SELECT article.* , section.title, category.title, user.name, user.name
FROM article
INNER JOIN section ON article.section_id = section.id
INNER JOIN category ON article.category_id = category.id
INNER JOIN user ON...
I have a String Array in a java program. I am using jdbc driver to store data in MySql.
There is a reference variable "pstmt" that refers to a prepared statement
now I want to call the following method:
String [] items = {pen, ball, speaker, mic};
pstmt.setArray(1, ....);
where "items" refer to String array but the method setArray...
Trying to get two different counts in one query. To do this I am selecting from a table and need to join another one. Check out the (not working) queries below. These were different ways I was trying to do it - unsuccessfully.
Is this possible, and if so can you offer assistance getting a working query?
SELECT
count( tasks_assigned.t...
$dml = "insert into ... ";
mysql_query($dml,$con);
$Id = isset($row) ? $row['id'] : mysql_insert_id($con);
I saw the record is created,but just can't retrieve the Id.
What's wrong?
EDIT
fixed,it's caused by $row.
...
I believe that I am having a bad database design and need some help to improve it.
I am having three tables for my blog posts.
Posts
-id
-title
Categories
-id
-name
CategoryBindings
-id
-postId
-categoryId
Let say that I have this data:
Posts
1 Title1
2 Title2
Categories
1 category1
2 category2
CategoryBindings
1 1 1
2 1 2
3 2 1
...
I have two tables products and sections in a many to many relationship and a join table products_sections. A product can be in one or more sections (new, car, airplane, old).
Products
id name
-----------------
1 something
2 something_else
3 other_thing
Sections
id name
-----------------
1 new
2 car
Products_...
We are getting a lot of deadlocks during certain queries, and we believe it is due to the gap locking due to the fact that we are inserting lots of rows into this table.
If we eliminate the autoincrementing primary key field (since we don't ever use it) ... will this get rid of the gap locking?
...
This is a problem I often run into, and my solution has always to run numerous queries, but I feel there must be a better way. Here are my two tables for this example:
Artists
id
name
Songs
id
artistID
name
genre
The table are linked as such:
artists.id <-> songs.artistID
I'd like to fetch a list of all artist...
I have had numerous headaches trying to get the MySQL APIs for Perl and Python working on my 64 bit Macbook Pro (Leopard). I installed the 64 bit version of MySQL, but Googling around now I have the impression that this could be the source of my pain. None of the various blogs and SO answers quite seem to work (for example here on SO)
...
Application was initially developed in VS 2008. It uses MySQL.data.dll for connecting to MySQL database. Application runs perfectly fine in Windows.
But production environment is Debian with mono.
Now copied entire solution in the Debian box. Entire solution opens in monodevelop correctly. It doesn't throw any error in building. But ...
If I have a table with important 2 columns,
CREATE TABLE foo (id INT, a INT, b INT, KEY a, KEY b);
How can I find all the rows that have both a and b being the same in both rows? For example, in this data set
id | a | b
----------
1 | 1 | 2
2 | 5 | 42
3 | 1 | 42
4 | 1 | 2
5 | 1 | 2
6 | 1 | 42
I want to get back all rows exce...
Hello
note: to the editors: please edit the title if have a better one :)
my question is:
I have two tables in my database
-----------
| table1 |
|----------|
| id |
|text |
===========
-----------
| table2 |
|----------|
| id |
|text |
==========...