It's been three hours.

Source: Internet
Author: User
It took three hours for the villain to stop, mysql is a mess ..................................... ..... please help me ..........................

My goal is to store the query results as a temporary table. my SQL statement is as follows:


Select a. value, a. id, B. value from a, B where a. value = B. value as k;


An error occurs ...................................... ..... what is the correct syntax ??

Both tables exist.


The corresponding field also exists.


I think there should be errors in the syntax. what is the correct syntax ??

100,000 in a hurry. thank you very much !!!!!!!!!!!!!!!!!!!!!


Reply to discussion (solution)

If an error is reported, an error message is displayed.
The error message shows the location where the problem occurs.

As k seems to have a problem. remove it and try again.

Select * from (select a. value, a. id, B. value from a, B where a. value = B. value) k;

Select * from (select a. value, a. id, B. value from a, B where a. value = B. value) k;



Still not ............ Copy it according to your statement, or an error occurs...

It should be just a statement problem. I just want to store the query results as a temporary table, which is very simple and hard to write.

If an error is reported, an error message is displayed.
The error message shows the location where the problem occurs.



Moderators help me. I just want to store the query results as a temporary table k, which is very simple.

What is your statement? paste it out and check it out.

create temporary table k select a.value,a.id,b.value from a,b where a.value=b.value

However, temporary tables can only survive in the current connection.




If an error is reported, an error message is displayed.
The error message shows the location where the problem occurs.



Moderators help me. I just want to store the query results as a temporary table k, which is very simple.

Create table temp_table as select * from table;

To create a temporary table, use create temporary table tablename to insert data.
Run phpmyadmin to view the result.

create temporary table k(  `a` varchar(20) NOT NULL,  `aid` int(11) NOT NULL,  `b` varchar(20) NOT NULL);insert into k(a,aid,b) select a.value,a.id,b.value from a,b where a.value=b.value;select * from k;

The sentence written by the moderator needs to be changed.

create temporary table k select a.value as aval,a.id as aid,b.value as bval from a,b where a.value=b.value;select * from k;


Otherwise, there will be two values, resulting in an error. #1060-Duplicate column name 'value'

With k as (select a. value, a. id, B. value as value1 from a, B where a. value = B. value) select * from k
Or
Select * from (select a. value, a. id, B. value as value1 from a, B where a. value = B. value) k
Note that there cannot be repeated fields in select a. value, a. id, and B. value.

Not closed? What's the problem?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.