MySQL Forums

Syndicate content
Updated: 59 min 12 sec ago

PAGING: mysql_fetch_assoc($rs) vs mysql_num_rows($rs) (no replies)

1 hour 15 sec ago
Hi,

I have selected first 20 records with the combination of inner and left join in mysql select query for php page. Now, I would like to implement paging (single record on each page). If we use select.... limit 20; then paging becomes difficult and if we use select .... limit 0, 1 then it might return more than 20 records to be page.

So, i wish to write loop statement like:-
while ($row_rs = mysql_num_rows($rs) <= 20);
instead of
while ($row_rs = mysql_fetch_assoc($rs));

I would like to know, will it return same results as we expect from mysql_fetch_assoc($rs) and how much it is practical way to solve the problem.

Thanks

copy columns in tables (no replies)

Sat, 2008-09-06 23:38
I am new to Mysql and Workbench, How do I copy columns from one table to another, I have 26 Tables all with the same columns,ie. NAMEA, NAMEB, NAMEC......NAMEZ
Thanks

query without subqueries (1 reply)

Sat, 2008-09-06 22:59
Hello all!
I'm developing an inverted index search as a toy problem to learn SQL in general and MySQL specifically. I was wondering wether or not it's possible to solve this problem without using subqueries:
I use a table as a reverse index, where an id specifies a file's id and txt is a word contained on that file, something like:
create table t ( `id` tinyint(4) NOT NULL, `txt` varchar(21) NOT NULL, PRIMARY KEY (`id`,`txt`) ) For our little example, the table can contain:
id | txt
1 | "a"
1 | "b"
2 | "a"
So document 1 contains words "a" and "b", while document 2 contains only the word "a".
I could sucessfully perform "AND" and "OR" operations (like searching "a OR b" or "a AND b"), just using inner joins:
Example of query "a AND b":
SELECT t0.id from t as t0 inner join t as t1 on t0.id=t1.id where t0.txt!="a" AND t1.txt="b" I was even able to implement full text search (like searching " 'a b' ") just adding a "position" field. But I just can not figure out how to perform a NOT operation.
The question is "how to retrieve the id of the documents containing the word "a" but NOT the word "b"?.
Just for it serves as an inspiration, here it is a query wich solves the problem BUT using subqueries:
SELECT t0.id from t as t0 inner join t as t1 on t0.id=t1.id where (t0.txt!="b" AND t1.txt="a") and t0.id not in (select id from t where txt="b")
Any suggestion or explanation about solving the problem or demonstrating that the problem has no solution is very welcome

Problems with CAST and CHARACTER SET (no replies)

Sat, 2008-09-06 22:43
Hi guys,

I do not even know if this is the best place to post this, but i didn't find another place where i should do it.

I would like to know why does this work fine:

SELECT CAST(_latin1 'São' AS CHAR CHARACTER SET utf8) from rw_city;

BUT, this does not:

SELECT CAST(_latin1 dsc_city AS CHAR CHARACTER SET utf8) from rw_city;

I need to make a comparison between two tables and one is in latin1 and another in utf8, I want to convert the latin1 characters to utf8 just in my select.

How could I achieve this?

Thanks in advance

order by case sensitive (1 reply)

Sat, 2008-09-06 21:45
Hello.

the query:

select name
from tb_users
order by name

is case sensitive.
Eg.:
Andrew
Jacob
Michael
andrew
jacob
michael

What I have to do to the result be like this:

andrew
Andrew
jacob
Jacob
michael
Michael

thks in advance!

Question, how to manage more than one article in a table (no replies)

Sat, 2008-09-06 20:56
Hey @all

So, I try to explain, what I have.
Till yet, I have had two order tables, but I got many problems with getting the right invoice number, select all of my articles, and so on...
So, I thought, I bring the two tables together, to only one table. The idea behind this, is that I only have one table, which should be referenced to a child table with all my articles, so that the searching of articles will be much more easier.
But I have the problem, that my brain is overheating, because I don't know how to realise it.

I have (as I sayed above) two different order tables. - Let's say: Orders A & Orders B
The Orders A can contain two articles (one for the right side & one for the left side) - One Order can have as maximum these two articles (1:1 relation)
The Oders B contains "only" one articel, BUT One order can have 'n' articles stored. (1:n relation)

How do I have to design my tables correct, so that it will be correct!?

THX

Tabellenaufbau mit mehreren, aber gleichen Feldern (no replies)

Sat, 2008-09-06 20:46
Hallo NG

Ich suche eine Lösung für mein Problem. & zwar Möchte ich eine Tabelle für
alle meine Aufträge erstellen.
Ich habe 2 grundlegend verschiedene Auftragstypen. - Dafür habe ich alle
benötigten Felder in der Tabelle erstellt. Da komme ich aber schon zu dem
Punkt, wo ich nicht mehr weiter weiß....
& zwar: Beide Aufträge müssen Artikel verwalten (logisch...). Das Problem
(für mich) ist jetzt folgendes:
Auftrag A muss 2 Artikel verwalten. - Für die rechte Seite & für die linke
Seite. Pro Auftrag können demzufolge max 2. Artikel eingetragen werden -
Auftrag B verwaltet hingegen beliebig viele Artikel pro Auftrag.

Wie baue ich da die Tabelle richtig auf?
Danke für jeden Tipp im Voraus

MySQL Storing... (no replies)

Sat, 2008-09-06 20:36
Hello,

I have a php script that generates randon numbers for a game i am working on, but i can't seem to figure out how to store the generated numbers into a database after they have been stored.

This is possible isn't it?


Thanks,

Dan

Problem with hebrew search (no replies)

Sat, 2008-09-06 16:43
Hi,
In hebrew there are words that use the quotation mark (").
It seems that the full text search doesn't find this words.
Any suggestions?
Would appreciate your help.
Thanks.
Dror

Data Privacy at Any Cost (no replies)

Sat, 2008-09-06 16:22
Transaction data is a major cause of concern in any organization. Being a financial institution it was a constant challenge to protect sensitive data that usually leaks out from the GUI. To top it was the issue of ever growing application database that triggered the red alarm almost every other day. We found the perfect fix in the form of ‘Data Privacy Pack for Oracle E-Business Suite’ – a complete centralized manager for data classification and security aspects. It was worth every penny spent. For more information visit
http://www.solix.com/data_privacy_oracle_ebusiness_suite.htm

root password lost (1 reply)

Sat, 2008-09-06 13:08
Hi,

I am an Oracle DBA and new to MySQL. I have to do some urgent work on MySQL but problem is that I have been assigned a user/password which does not have access to grants tables (mysql schema). My user has access to only one database, and is allowed to connect only from the same machine which hosts the database (which is on linux).

So, I am not able to connect to database from my Windows machine having GUI database client tools. The actual DBA of the system who had root password has gone and now nobody knows the mysql's root user password. I wanted my user to be able to connect remotely which requires changes in grant tables, but only root user can grant this priviledge.

Can someone please help me? how can i get the priviledges that only root can grant? is there a way to know root password or, to reset root's password? plz help.

Thanks in advance.

list of companys to work freelance or set up an independent home business (no replies)

Sat, 2008-09-06 12:59
if you like to heare about it leave your email here or contact me at borjaobeso@hotmail.com and i will send you the information

take care

Slow insert on my PC but fast on my Laptop? (1 reply)

Sat, 2008-09-06 12:52
Hi there,

I'm just wondering what can be the cause of slow inserts on my PC but super fast on my Laptop?

I'm using MySql x64 on both PC. Operating System should be also identical as I mirrored it between these two PCs but PC would have more programs running.. Settings on my MySql should be identical unless there's more than just Server Instance Config Wizard.

My PC is definately faster in terms of CPU and Hard drive compared to my Laptop. But insertion on laptop was like 10x faster.

Any ideas what I could have set wrongly?

MYSQL Enter key problem (no replies)

Sat, 2008-09-06 12:48
I am facing a problem while I am trying to add some data through a form textarea. Let say I have a address field in form. I am using textarea for that. I have a mysql table which has a `address` column and type has been specified as varchar(150). I have also added a JavaScript counter to restrict user to enter more than 150 characters. If user enters 250 characters without pressing enter button within the textarea data has been inserting properly in mysql table. But when user press enter button betwwen 2 lines and entering 150 characters data is not inserting in database properly, example:
aaaaaaaaaa
bbbbbbbbbb
cccccccccc
dddddddddd
eeeeeeeeee
ffffffffff
gggggggggg
hhhhhhhhhh
iiiiiiiiii
jjjjjjjjjj
kkkkkkkkkk
llllllllll
mmmmmmmmmm
It's inserting data in following format
aaaaaaaaaa
bbbbbbbbbb
cccccccccc
dddddddddd
eeeeeeeeee
ffffffffff
gggggggggg
hhhhhhhhhh
iiiiiiiiii
jjjjjjjjjj
kkkkkkkkkk
llllllllll
mmmmmm
As you can see from above that data has been truncated. I have found out the reason. As we all know enter key equivalent to '\n'. Mysql is treating this 'n' as a character. Can we specify this '\n' as a escape character like '\'?

Linking Tables (no replies)

Sat, 2008-09-06 10:54
I have a database for storing contacts.

This database has 2 tables.
One is basic information about the contact.
The other table contains more specific information about the contact.

The data is entered into the tables via a php page.

What I need to know is how to link the tables so that data entered into the form is "linked" between the two tables. In other words, if data from the first 3 fields of the form is entered into one table, I want to make sure the other fields that put data into the other table is "linked" to the data entered into the first table so that when I query the database based on an ID, data is returned accurately from both tables.

I've read about primary keys ... and I've created a "unique_id" column in both tables that auto increments an id. But I don't know how to make sure that the id fields in both tables cooresponds to the same data entered via the form.

Ugh ... hopefully I haven't clobbered the description of what I want to do and someone can help me.

Thanks a bunch.

Paul

Could not setup Mach task special port 9: (os/kern) no access (no replies)

Sat, 2008-09-06 10:35
HI

I am getting this error in my console when I try to use mysql on mac. In terminal, it simply tells me that :"ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"

but in console it gives me this error: "Could not setup Mach task special port 9: (os/kern) no access"

anyone know whats going on?

thanks

Primary Key confuses me (3 replies)

Sat, 2008-09-06 10:15
Hello friends,

What exact purpose do Primary Keys serve for the ISAM engine, while we could just use ordinary unique indexes, to make them technically the same as Primary Keys?

Why cannot we just use a unique index and we have to use Primary Key, instead?

Is it only because Primary Keys do not accept NULL values and unique indexes do?

Is it something related to JOIN query and its need for Primary Key existence?

I have done a thorough and vast research on it and I still could not find the answer that was satisfactionary and convincing enough for me. This is really confusing to me. I will greatly appreciate any help. Greetings, Daniel

HELP! Problem with ampersand in WHERE Query (3 replies)

Sat, 2008-09-06 10:05
I need some help with a WHERE query I am running and I keep getting a syntax error;

I have a table with a record `category` and in it has a value of 'Audio & Video'

When I run the Query

SELECT *
FROM maintable
WHERE `category` = 'Audio & Video'

it gives me a syntax error. I believe it has to do with the &. I am not sure if it is encoded. I can get the right output if I use the

WHERE 'category' LIKE '%Video'

But it is very slow. Too slow.

Any help is so appreciated. Thank you so much in Advance.

logic for storing a particular data into databse (1 reply)

Sat, 2008-09-06 09:57
Hi guys.........here is my problem........


Suppose I have two questions(in the below given format) and I have to store them in databse.....with some meta info attached with each question........and during retrieval i can choose to retrieve either one of the questions or both..it depends:

Q.1 Which is the correct structure of benzene?

A) <structure-1> B) <structure-2> C) <structure-3> D) <structure-4>

Q.2 For the following equation:
H2SO4 + NAOH => Na2SO4 + H20 //////the equation would be in textbook format
What is the energy consumed in the process?

Now the above is my data.....i am in dilemma as to how to store these questions so that it enables question based retrieval..the problem is due to the images and equations shown above.....should I classify equations and tuctures as images and other data as text??? I yes then how do i store each of these images????


Thanks is advance

scheduling a backup (no replies)

Sat, 2008-09-06 09:07
Hello, I would like to schedule a daily backup for my DB using MySQL Administrator.
I have set everything up: I have created a schedule project, I have checked 'Schedule this backup project', i have defined the path and the time but it doesn't start. However if I click 'Execute backup Now' it works fine.
Am I missing something?

THANKS