| | Wed Dec 19, 2012 8:37 pm | | |
| Comments: 1 Views: 8763 |
|
Data saved in excel or other spreadsheet formats can easily be feed into a MySQL table using the Load Data function. The first thing to do is save/export your data from your spreadsheet in a tab-delimited format. Here is an example: "John Doe" "1111 test St" "555-555-5555" "Jane Doe" "1111 test St" "555-555-5555" If you had a text file with each piece of data seperated by tabs, and a new row of information on each line, you can easily import this data into a MySQL table. Example Table: create table customers( ID int not null auto_increment primary key, Name char(100), Address char(100), Phone char(12) ); To get your text file data into the MySQL table about you would run this command in MySQL. mysql > Load Data local Infile '/customer.txt' into table db.customer fields terminated by 't' enclosed by '"' lines terminated by 'rn'; Note: rn mean new lines. r means carriage return. n means new line.
| |
| | Thu Nov 03, 2011 7:24 am | | |
| Comments: 2 Views: 4667 |
|
MySQL select statements allow the use of “OR” or “||” to choose two or more possibilities in a single statement.
We will use the following database table as an example. mysql> select * from Name; +----+--------+---------------------+ | ID | Name | StartDate | +----+--------+---------------------+ | 1 | Joe | 2001-02-12 00:00:00 | | 2 | Jack | 2003-03-15 00:00:00 | | 3 | John | 1980-05-15 00:00:00 | | 4 | James | 1994-09-21 00:00:00 | | 5 | George | 1996-12-11 00:00:00 | +----+--------+---------------------+ |
1. If we wanted to select a single matching date from this table of information then we might write something like the following. mysql> select * from Name where left(Date,3)='200' && Name like '%J%'; +----+------+---------------------+ | ID | Name | Date | +----+------+---------------------+ | 1 | Joe | 2001-02-12 00:00:00 | | 2 | Jack | 2003-03-15 00:00:00 | +----+------+---------------------+ |
You may notice we added “Name like '%J%'” along with the left(Date,3)='200'.
2. If we wanted to get either a 21st century date or a 1990's date, we might use the following. mysql> select * from Name where left(Date,3)='200' && Name like '%J%' || left(Date,3)='199'; +----+--------+---------------------+ | ID | Name | Date | +----+--------+---------------------+ | 1 | Joe | 2001-02-12 00:00:00 | | 2 | Jack | 2003-03-15 00:00:00 | | 4 | James | 1994-09-21 00:00:00 | | 5 | George | 1996-12-11 00:00:00 | +----+--------+---------------------+ |
Here you should notice that the name “George” was also pulled in, despite the fact that we selected “Name like '%J%'”. Using the “||” or “OR” option in the select forces both sides of the “||” to be literally selected. To achieve the desired result of 21st century or 1990's dates and only names that begin with the letter “J”, we must use the following statement. mysql> select * from Name where left(Date,3)='200' && Name like '%J%' || left(Date,3)='199' && Name like '%J%'; +----+-------+---------------------+ | ID | Name | Date | +----+-------+---------------------+ | 1 | Joe | 2001-02-12 00:00:00 | | 2 | Jack | 2003-03-15 00:00:00 | | 4 | James | 1994-09-21 00:00:00 | +----+-------+---------------------+ |
By mixing the “||” and “&&” switches you can find data in a single table or multiple tables.
| |
| | Thu Jun 23, 2011 8:43 pm | | |
| Comments: 0 Views: 339 |
|
This is the second in a series of articles attempting to look at how programs are built and how one would begin to think about building their own search engine. This article is about understanding the nature of taking shortcuts and how the major search engines need these to perform up to current expectations. The first thing you want to do is determine what you want to accomplish. If I were starting my own search engine then I first want to think about what exists and why. What don't I like about Google or Yahoo! search or MSN search.
In regards to Google and the other major search engines, everyone dislikes bad results. But you have to determine what is a bad result. If you are searching for contemporary information then for the most part the results are easy to find. This is especially true with Google's search engine, since they frequently source news collections sites, such as Digg. And it is a point like this that needs to be highlighted. This is one of many shortcuts that Google takes to have better results. If there were no public relation sites, such as openpr.com or news aggregators, such as digg.com then Google would have a tougher time getting those results to the public. They would have to work much harder at understanding what is todays news and what is yesterday's news. And yesterday's news is just history, locked in documents called web pages.
So news sites, public relation sites and so on are shortcuts that Google has capitalized on to make sure their results are better, then if they were simply relying on their own algorithms. Another of these shortcuts are separate programs to interpret certain types of search queries. Let's use the example:
“grams in a pound”
The first thing you will notice is that they get the right answer. The next thing you should realize is that they had to write a separate program to deal with that type of language. They provide their traditional results, but also the answer to your question.
But if you try a little different search, say “1 pound is x grams”, they do not translate this into their program. You just receive the traditional results - and this is a matter of differentiating language, something which at this point needs to be very hard-coded.
So lets say that:
1.We want to produce good results 2.We don't want to write separate programs specific to certain topics
But we must understand the nature of shortcuts, and since the web changes (i.e., all sorts of people out there are adding all sorts of new structures all the time), the search engine's role must adapt. I suppose the ideal situation is some all-encompassing artificial intelligence that would adapt on its own, understanding that the web changes and that people are changing it. But for now lets further understand the use of shortcuts and how to make them work better.
| |
|
Search Marketing Articles
|