Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ok, bear with me, this is the newbie section and i did do another 4 hours of fail since my last post so, here it goes, i finally made a database called "log"
got the tables_in_log
to show: articles
searchwords
heck, i can even input queries:
insert into articles values(0, 'log' '8/30/10 zcaptain ');
insert into searchWords values(0, 'log', '1');
insert into searchWords values(0, 'ahsim', '1');
insert into articles values(0, 'home', 'home page');
insert into searchWords values(0, 'home', '2');
etc etc
all show
query, OK 1 row affected.
but when i run a search for say,"log" in my new snazzy search box
(courtesy of Whim sturkenboom in my php parshe error link down the page)
and it runs the search but returns:
Query select articleIds from searchWords where word = 'log' failed: Unknown column 'articleIds' in 'field list'
ok, bear with me, this is the newbie section and i did do another 4 hours of fail since my last post so, here it goes,
with mysql vers 5.1.36, i finally made a database called "log"
got the tables_in_log
to show: articles
searchwords
heck, i can even input queries:
insert into articles values(0, 'log' '8/30/10 zcaptain ');
insert into searchWords values(0, 'log', '1');
insert into searchWords values(0, 'ahsim', '1');
insert into articles values(0, 'home', 'home page');
insert into searchWords values(0, 'home', '2');
etc etc
all show
query, OK 1 row affected.
but when i run a search for say,"log" in my new snazzy search box
(courtesy of Whim sturkenboom in my php parshe error link down the page)
and it runs the search but returns:
Query select articleIds from searchWords where word = 'log' failed: Unknown column 'articleIds' in 'field list'
Please cut/paste:
a) your exact "select" query
b) "describe YOUR_TABLE" (substute your actual table name for "YOUR_TABLE")
c) the exact error
d) use "code blocks" when you cut/paste
Query select articleIds from searchWords where word = 'homepage' failed: Unknown column 'articleIds' in 'field list'
so, article Id's isnt in my field, but i cant find a way to put them there
hard to copy paste from mysql lol,
Code:
SHOW database *results in*: -----------
database
----------
information
content
log
use log
*results in*
Database changed
SHOW tables *results in* --------------
tables_in_log
--------------
articles
searchwords
a EXPLAIN searchwords *results in*
-----\-----------\-------\-------\--------\---------\
field type null key default extr
------\----------\-------\-------\--------\---------\
wordId int(11) NO PRI NULL auto_increment
word varchar(50) YES NULL
article varchar(255)YES NULL
also, link above wasnt solved, when i tried to update the first to include my mysql vers, not knowing if that was the issue, it duplicated, so, i marked one as solved as i couldnt find a remove..
-----\-----------\-------\-------\--------\---------\
field type null key default extr
------\----------\-------\-------\--------\---------\
wordId int(11) NO PRI NULL auto_increment
word varchar(50) YES NULL
article varchar(255)YES NULL
then the problem is that your table doesn't have an "articleID' column. Basically, you're asking for something that doesn't exist.
-----\-----------\-------\-------\--------\---------\
field type null key default extr
------\----------\-------\-------\--------\---------\
wordId int(11) NO PRI NULL auto_increment
word varchar(50) YES NULL
article varchar(255)YES NULL
then the problem is that your table doesn't have an "articleID' column. Basically, you're asking for something that doesn't exist.
oh i understand that now, ive been looking for a way to modify it, i now have a table "articlesId"
but searchwords still no go, same input, same error
select articleIds from searchWords where word = 'homepage';
2. Please "describe searchwords;":
Code:
-----\-----------\-------\-------\--------\---------\
field type null key default extr
------\----------\-------\-------\--------\---------\
wordId int(11) NO PRI NULL auto_increment
word varchar(50) YES NULL
article varchar(255)YES NULL
3. Please cut/paste exact error message:
Code:
Query select articleIds from searchWords where word = 'homepage' failed: Unknown column 'articleIds' in 'field list'
Soooooooo ....
As Hangdog42 said: you're asking for something that doesn't exist!
Here's are a couple of alternative queries that should work:
Code:
select wordId from searchWords where word = 'homepage';
select * from searchwords;
select * from searchwords where word = 'homepage';
select wordId, word, article from searchwords where word like 'home%';
...
'Hope that helps
PS:
I'm assuming your table is called "searchwords", and not "articleId".
If you had a table for articles, I'd call it "Articles", or "ArticlesTable"; and "articleId" (or simply "id") would be a COLUMN in your "Articles" table.
PPS:
I've found this book very helpful for learning SQL:
now have a table "articlesId"
but searchwords still no go, same input, same error
Having a table "articlesId" isn't the problem here. Let's parse your query:
Quote:
Query select articleIds from searchWords where word = 'homepage'
The "select artticleIds" says that you're looking for data in the column articleIds. The part "from searchWords" says that the column articleIds lives in the table searchWords. The part "where word = 'homepage'" says that you're looking specifically for the rows in searchWords where the column word has the value "homepage". So at very minimum for this query to work, your table searchWords has to have the columns articleId and word. Given the columns that you have shown us, the queries 14moose posted should work.
i am not asking for a handout, i have been and continue to try, but, ive been stumped for a day and a half, over something other forums wont help w/
-----------------------------------
alright, so, i know its requesting a column article ids that dont exist.
i 'll include the entire mysql i had done initially,
Code:
create database log;
use log;
create table articles
(
articleId int auto_increment,
title varchar(50) not null,
content text,
primary key(articleId),
unique id(articleId)
);
create table searchWords
(
wordId int auto_increment,
word varchar(50),
articleIds varchar(255),
primary key(wordId),
unique id(wordId)
);
i created the initial search words entering
Code:
insert into articles values(0, 'log', 'ahsim zcaptain');
then
Code:
insert into searchWords values(0, 'log', '1');
insert into searchWords values(0, 'ahsim', '1')
insert into searchWords values(0, 'zcaptain', '1')
moose14's querys: here are the results
Code:
select wordId from searchWords where word = 'homepage';
*results in*
+------+
word id
+------+
11
16
17
--------
Code:
select * from searchwords;
+-----------------------------+
wordID| word | article |
+-----------------------------+
1 log 1
2 ahsim 1
3 zcaptain 1
4 home 2
5 about 3
6 home 2
7 log 1
8 ahsim 1
9 zcaptain 1
10 home 2
11 homepage 2
12 log 1
13 ahsim 1
14 zcaptain 1
15 home 2
16 homepage 2
17 homepage 2
18 log 1
19 ahsim 1
20 zcaptain 1
21 home 1
22 log 1
23 ahsim 1
24 zcaptain 1
25 home 2
26 home 2
Code:
select * from searchwords where word = 'homepage';
*results in*
wordId | word | article
-------------------------
11 homepage 2
16 homepage 2
17 homepage 2
now,the last one
Code:
"select wordId, word, article from searchwords where word like 'home%';"
this one just brings up every "home" i listed beforehand
now, obviously every time i "insert search word" it registered
i just need to know how to add the proper column (articleId?),
and /or affect the column in the right area,
clear all my old homes zcaptain's and the like
basically, i just figured if i wanted to search the word "log" and have it find it, id just: insert intoarticle values (0, log, "1")
but, since ahsim or zcaptain,are also (0, *, "1")
i wanted a search of them to grab log as well,
and a search home or homepage, to both pull the same page since theyre both "2"
is that flawed?
I appreciate all the effort you guys are investing in attempting to enlightenin this fool.
I think this is starting to make some more sense, but I've still got a couple of questions:
- When you create the searchwords table, you create an articleIds field. However, in your dump of the table (select * from searchwords) the field appears as "article". That isn't necessarily a fatal flaw so long as your SQL statements use article.
-Am I correct in assuming that the article field in searchwords is the same data as articleID in the articles table?
Assuming this is the case, the following might do what I think you're after
Code:
SELECT a.articleID FROM articles a, searchwords b WHERE b.word='homepage' AND a.articleID=b.article
Essentially since you want results from your articles table, but are querying using data in your searchwords table, you have to construct a query that tells SQL how the two tables relate.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.