drrw8672 2013-10-09 08:30
浏览 27
已采纳

标记表条目不会在选择/使用该行条目后再次显示

I am a beginner in programming and I don't know if my title suits my issue, but here is what I am dealing with:

I made a simple inventory program. I can insert, edit and delete entries and it all works perfect. For my next challenge I need to make it that when an item gets sold out of the inventory that my database will flag that entry so that it will not show again in that list in the application. (Makes sense right? when u sell a product it can't still be there cuz its sold)

But since I am a beginner I have no idea whats o ever how to research this cuz I have never done this before! That's why its a challenge :)

Can you pls tell me what I should research to learn about how I should be doing this ? Thank you in advanced for ur advice and attention! And my apologies if this question is off-topic to this website but I don't know where else to ask since this website is so awesome! Cheers

  • 写回答

1条回答 默认 最新

  • dongzan0108 2013-10-21 14:17
    关注

    If products are coming INTO your inventory you would need to scan the products and the amount of how much has come in right? When you do this for a product you would just update the record with the ID of the product that has come in(By scanning the product you should get the ID I assume) and the update query could look something like this:

    UPDATE myTable SET productStock=productStock+amount* WHERE productID = ID* 
    

    *Amount stands for the amount that came INTO your inventory.

    *ID stands for the ID of the product.

    The above was an intro, now your question which you can lead off of the above, when a customer wants your product, and clicks on it, orders it, you can do the UPDATE query again, but now MINUS 1 or whatever the amount the customer orders(again by doing multiple amounts you should always check if you have it in stock, but that's another part)

    UPDATE myTable SET Stock=Stock-amount* WHERE productID = *ID
    

    *Amount now stands for the amount that the customer orders OUT OFF your inventory.

    *ID stands for the ID of the product.

    When your "productStock" turns 0, you could simply modify or add a query which will only show values where the "productStock" IS NOT 0.

    Example:

    SELECT * FROM products WHERE productStock <>* 0;
    

    *<> This symbol stands for NOT EQUAL and in some versions of SQL this is written as !=

    Hopefully this would help you on your way.

    EDIT:

    Why you should not 'flag' or 'remove' the product out of your DB is because when it returns you don't have to fill in the entire product again...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题