0

Let´s say i perform a query like this:

$charsnamequery = mysql_query("SELECT * FROM 'bookstable' WHERE 'bookcharactersname' = 'JHON'")

This will give back a resource that i then put in an array and use to print the results like this:

while ( $fullist = mysql_fetch_array( $charsnamequery ))
{ Print "book title: ".$fullist['id_book'] . ", book author:".$fullist['book_author'] . "
.....etc etc etc";
 }

So, lets say that now i want to do is: Search on my database for customers who have showed interest in any of those id_book in the past and gather their emails.

I know i am suposed to reformat the array in someway so that i can do a new query like:

$newquery = mysql_query("SELECT 'email' FROM 'customerstable' WHERE 'id_book_interested_in' IN ($value1,$value2,$value3....etc etc etc)"

Hope you can give me a hand with this! Thanks you in advance!

PS: I rather not join the querys even if it were possible for im trying to learn step by step.-

2

1 Answer 1

1

The reason why the query is not working is because you are wrapping the table name as well as column name with single quote.

SELECT * FROM bookstable WHERE bookcharactersname = 'JHON'

These are identifiers and not string literals. In this case, backticks are optional since non of them are reserved keywords.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the info. I guess i just wrote it down badly while posting the question. My actual issue it with getting the "SOMEWAY" (highlighted on the text) done. That is the step i do not know how to perfom

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.