LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   input articleIDs (https://www.linuxquestions.org/questions/linux-newbie-8/input-articleids-830318/)

zev42 09-04-2010 09:17 AM

input articleIDs
 
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'


please alleviate my blinding stupidity!

much thanks for reading such a long post

zev42 09-04-2010 09:20 AM

input articleIDs
 
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 alleviate my blinding stupidity!

much thanks for reading such a long post

14moose 09-04-2010 10:08 AM

Hi -

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

TIA!

14moose 09-04-2010 10:11 AM

Please see the other post.

Even if you solved the problem, please cut/paste your original query (and how you solved it) so others can learn.

TIA!

zev42 09-04-2010 10:31 AM

exact error:

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..

sry for the inconvinence

Hangdog42 09-04-2010 11:09 AM

Quote:

select articleIds
If this bit are the fields in your table:

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

then the problem is that your table doesn't have an "articleID' column. Basically, you're asking for something that doesn't exist.

zev42 09-04-2010 11:35 AM

grok
 
Quote:

Originally Posted by Hangdog42 (Post 4087976)
If this bit are the fields in your table:

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

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

14moose 09-04-2010 12:17 PM

Here's what I was trying to ask you:

1. Please Cut/paste exact query (use LQ "code blocks"):
Code:

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:
Quote:

SQL Queries for Mere Mortals, by John Viescas and Michael Hernandez
It takes you from "What is SQL" to some fairly sophisticated queries - all pretty painlessly. Very practical; highly recommended!

Hangdog42 09-04-2010 12:31 PM

Quote:

Originally Posted by zev42
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.

zev42 09-04-2010 05:02 PM

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:D

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.

zev42 09-04-2010 09:52 PM

ive been trying to modify the existing searchwords table to include field (articleId)

still no prevailance

Hangdog42 09-05-2010 01:25 PM

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.


All times are GMT -5. The time now is 02:34 PM.