MySQL:将数据写入表和列
在大学学习网络开发课程时,我一直在浏览数据库时感到恶心。我已经阅读了大多数内容,例如连接到 mysql、选择数据库等等。但我无法弄清楚如何在表的列中添加数据。
我已经尝试了在网上可以找到的内容,但我没有找到任何有用的东西...所以我想知道这里是否有人能好心地向我展示如何将内容写入包含这些列的表中: http://imageshack.us/photo/my-images/851/sqla.png/
我不需要帮助来选择数据库等等,只是如何将这些数据写入数据库。或者像我这样的傻瓜指南的链接...我已经尝试了很多不同的方法
mysql_query(INSERT INTO *** VALUES ****)
但我无法让它工作..
任何帮助都会非常感激,感觉完全迷失了。
提前致谢!
Doing a university course in web development and I've been sick all the time we went thru databases. I've read up on most stuff, like connect to mysql, select DB and that. But something I can't figure out is how to add data in the columns of a table.
I've tried what i could find online but I haven't found anything useful really... So I was wondering if anyone here could be so kind to show me how write stuff to a table with these columns: http://imageshack.us/photo/my-images/851/sqla.png/
I don't need help to select DB etc, just how to write those data into the db. Or a link to a guide for dummies like myself... I've tried a lot of different ways with
mysql_query(INSERT INTO *** VALUES ****)
But I cannot get it to work..
Any help would be really appreciated, feeling totally lost.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的猜测是
song_id
与其他一些表相关,因此您需要在插入请求中具有有效的song_id
,但类似这样的操作应该有效:请注意 <如果 code>song_id 与另一个表相关,则应将其替换为有效的 id:
您还应该尝试检查 mysql 文档 此类的问题。
My guess is that
song_id
is related to some other table so you would need to have a validsong_id
in your insert request, but something like this should work:Notice that the
song_id
should be replaced with a valid id if it's related to another table:You should also try checking the mysql documentation for this kind of questions.
类似的事情应该可以解决问题。
这里有一个相当容易理解的参考
Something along the lines of this should do the trick.
There's a fairly easy to understand reference here
试试这个:
如果您想要这样的东西,一个有用的指南是 w3schools
Try this:
A useful guide if you want stuff like this is w3schools