Mysqli examples
Related articles:
- Mysqli SELECT query with prepared statements
- How to run an INSERT query using Mysqli
- How to run a SELECT query using Mysqli
- How to run an UPDATE query using Mysqli
- Mysqli prepared statement with multiple values for IN clause
- Using mysqli prepared statements with LIKE operator in SQL
- How to create a search filter for mysqli
- How to call stored procedures with mysqli
- How to run 1000s insert queries with mysqli?
Comments:
Two tables: posts and members inner join Each post in posts has a to_,emberid and a from,member_id. , the member names are in members. I am using 'as' and trying to fetch the member names as from_name and to_name based on the condition of who they are in posts.
Thoughts?
Hello, I'm writing a forum software. All "threads" and "post" are stored in one table (they are called a message - msg). And a "thread" have the field relate_to=0, a "post" (comment to a "thread" have the field relate_to=id of the thread. I'm told that this will hurt performance, it have to read the whole table, mixed with threads and post, to find e.g threads to list on the main page. So will using mysql/mariadb partitions help? Or this is another delusion?
Reply:
Hello!
Well, someone who told you that entire table will be read is not quite familiar with databases. There is a thing called index. All you need is to add index on relate_to. And so only relevant entries will be read from table.
I assume, you are planning to display entire thread with a query like this?
where, for both ? marks, the thread is will be used? If so, it's perfectly OK, and will never impact performance, only records that belong to certain thread will be read.
The same goes for listing all threads:
will only read post messages from index and won't read replies.
And no, partitions won't needed here. Your schema is very basic and would work for hundreds of thousands messages with most generic setup.
Hello ,I need subcategory when I click in category(food,milk) then show me subcategory(food1,food2), Do you know how I can fix this?
I cannot make this work: I have been told a million times to "review you query" but cannot find the issue. The query returns desired results on cmd line: <?php