I have Table1 and Table2 related on Table1.ID. There can be zero or more Table2 records for a given Table1.ID. I have a view where I want to get Table2.Value where Table2.ID is max for a given Table1.ID. A friend suggested a derived table, but that requires a subquery in the from clause, and MySQL doesn't like that. Are there any oth...
tmp-file contains:
database_1
database_2
database_3
I want to run a command like "mysqldump DATABASE > database.sql && gzip database.sql" for each line in the above file.
I've got as far as cat /tmp/database-list | xargs -L 1 mysqldump -u root -p
I guess I want to know how to put the data passed to xargs in more than once (and not j...
I am trying to fix a project that someone else coded, it is a mess!
On an edit user profile page they have something like this below which will list all available radio select boxes for the options a user can select for there education level, this is just 1 item, there is many items like it so based on the answers here, I can apply it...
I cannot for the life of me get this. Example of fails, the last line of which adds in sed, which is the ultimate goal:
find -maxdepth 1 -name "*.sql" -exec "mysql -D ootp < {}" \;
find -maxdepth 1 -name "*.sql" -exec "mysql -D ootp << {}" \;
find . -maxdepth 1 -name \"*.sql\" -exec /usr/bin/mysql -D ootp << sed -e 's/ , );/1,1);/g' {}
...
Is there any way to slip in a record to the top of a result set in MySQL? For instance, if my results are:
1 | a
2 | b
3 | c
etc
I want to be able to get:
Select | Select
1 | a
2 | b
3 | c
etc
Where "Select" isn't actually a part of the recordset, but artificially inserted.
Thanks.
...
Hi,
mysqlhotcopy works great for me to do the whole DB, but I can't seem to do a single table.
I thought this should work
/usr/bin/mysqlhotcopy mydb_cms./^SiteUsers$/ /db0/bkp --user=xxx --password=xxx --allowold --method=cp
When I run that I get:
No tables to hot-copy at /usr/bin/mysqlhotcopy line 396
That is the right DB and tab...
The way I currently do it in mysql is is
UPDATE table SET hits=hits+1 WHERE id = 1;
This keeps live stats on the site, but as I understand, isnt the best way to go about doing this.
Edit:
let me clarify... this is for counting hits on specific item pages. I have a listing of movies, and I want to count how many views each movie pa...
Is there a way to retrieve the auto generated key from a DB query when using a java query with prepared statements.
For example, I know AutoGeneratedKeys can work as follows.
stmt = conn.createStatement();
stmt.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);
if(returnLastInsertId) {
ResultSet rs = stmt.getGeneratedKeys();
...
When inserting a row in mysql database, string values need to be enclosed in quotes where integer don't need to.
Is there any class or library that takes care of this automatically so that I can just pass to a 3rd-party function an array of fieldnames and values and don't have to worry about putting string values in quotes?
Thanks,
...
I annotated a bunch of POJO's so JPA can use them to create tables in Hibernate. It appears that all of the tables are created except one very central table called "Revision". The Revision class has an @Entity(name="RevisionT") annotation so it will be renamed to RevisionT so there is not a conflict with any reserved words in MySQL (th...
I need to adjust the innodb_buffer_pool_size of my master and slave mysql database servers, both are running on independent boxes. On the slave if I issue "stop slave" i'm still not able to /etc/init.d/mysql stop to make the my.cnf change (Debian Lenny).
/etc/init.d/mysql stop
Stopping MySQL database server: mysqld failed!
and
/et...
Hello,
I have a table which has the following
id timestamp
-------------------------------------
1 1247046037
4 1247047437
5 1247047438
6 1247048738
Now I want to return all those ids which are 3 minutes apart from the previous id. In the above example it should return 1,4,6.
How should I go about doing this?...
I have installed WAMP server in my PC.When i installed all services are worked properly.On next day i started WAMP mysql service alone not working.I tried all the possibilities,the icon like half yellow and half white.i reinstalled the WAMP the mysql is working fine on that day only next day it wont work.Please help me...
Mysql latest ...
I have a table with products.
artID artName stock order
1 cables *100 0
2 cables *1 75
What should I do to asociate these 2 rows and get the stock in sync. The provider sells the cables in bulks on 100 units, and the retail store sells then as unit.
The idea is: when "cables *1" run nearly out of stock set the order row to 1 so...
I have a 'customers' table. Each record contains a customer name, email, address, etc.
I have an 'skus' table. Each record contains the name of an SKU. e.g. "Super Software Bundle".
An SKU represents a purchaseable item at a single price point. The purchased item can include one or more products.
e.g. The SKU record named "Super Softw...
I have a table which looks like
index customer_number ABC CWD ROE BEE
1 1 0 0 0 1
and I want to return only the field names that have value 1 in this case 'BEE'
I found that by SHOW FIELDS I can get the names of the fields but how I can say show the field names where field value = 1?
...
Greetings, fellow coders!
I have this table that contains categories and subcategories (actually I don't, but let's stick to a classic example):
Id ParentId Name
1 NULL A
2 1 B
3 2 C
4 3 D
5 NULL B
6 5 D
Is there a way for me to get cat...
So i need to run a jdbc call that is going against a sql server database.
CallableStatement cs = conn.prepareCall("{ ? = call " + spName + " ( ?, ?, ?, ?, ? ) }");
So the sql server call is a function that has output parameters.
we are using mysql database and it looks like mysql functions don't support functions with out put param...
I'm on a desktop PC, so I dont need Apache, MYSQL, PHP to run all the time on my main PC. Also I have all the good tools (adobe cs4, etc) on my XP box and they wont run on my Win2000 VM Guest, plus they would require another license even if they did. I'm not sure if its worth the trouble but figured I'd ask before I try to figure out how...
Hi, building a site using PHP and MySQL that needs to store a lot of properties about users (for example their DOB, height, weight etc) which is fairly simple (single table, lots of properties (almost all are required)).
However, the system also needs to store other information, such as their spoken languages, instrumental abilities, et...